Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename modules according to the new name #57

Merged
merged 7 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# langchain4k
# xefAI
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional
package com.xebia.functional.xef

import arrow.core.NonEmptyList

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional
package com.xebia.functional.xef

import io.github.oshai.KLogger

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.xebia.functional.agents
package com.xebia.functional.xef.agents

import arrow.core.raise.Raise
import com.xebia.functional.AIError
import com.xebia.functional.xef.AIError

interface Agent<in Input, out Output> {
val name: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.xebia.functional.agents
package com.xebia.functional.xef.agents

import arrow.core.NonEmptyList
import arrow.core.raise.Raise
import arrow.core.raise.mapOrAccumulate
import arrow.core.raise.recover
import com.xebia.functional.AIError
import com.xebia.functional.xef.AIError

// from https://docs.langchain.com/docs/components/chains/index_related_chains

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.xebia.functional.agents
package com.xebia.functional.xef.agents

import arrow.core.raise.Raise
import arrow.core.raise.catch
import arrow.core.raise.ensureNotNull
import com.xebia.functional.AIError
import com.xebia.functional.auto.SerializationConfig
import com.xebia.functional.auto.serialization.buildJsonSchema
import com.xebia.functional.llm.openai.LLMModel
import com.xebia.functional.llm.openai.OpenAIClient
import com.xebia.functional.prompt.PromptTemplate
import com.xebia.functional.prompt.append
import com.xebia.functional.vectorstores.VectorStore
import com.xebia.functional.xef.AIError
import com.xebia.functional.xef.auto.SerializationConfig
import com.xebia.functional.xef.auto.serialization.buildJsonSchema
import com.xebia.functional.xef.llm.openai.LLMModel
import com.xebia.functional.xef.llm.openai.OpenAIClient
import com.xebia.functional.xef.prompt.PromptTemplate
import com.xebia.functional.xef.prompt.append
import com.xebia.functional.xef.vectorstores.VectorStore
import kotlinx.serialization.KSerializer
import kotlinx.serialization.json.Json
import kotlinx.serialization.serializer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.xebia.functional.agents
package com.xebia.functional.xef.agents

import arrow.core.raise.Raise
import arrow.core.raise.ensure
import com.xebia.functional.AIError
import com.xebia.functional.llm.openai.*
import com.xebia.functional.prompt.PromptTemplate
import com.xebia.functional.vectorstores.VectorStore
import com.xebia.functional.xef.AIError
import com.xebia.functional.xef.llm.openai.ChatCompletionRequest
import com.xebia.functional.xef.llm.openai.CompletionRequest
import com.xebia.functional.xef.llm.openai.LLMModel
import com.xebia.functional.xef.llm.openai.Message
import com.xebia.functional.xef.llm.openai.OpenAIClient
import com.xebia.functional.xef.llm.openai.Role
import com.xebia.functional.xef.prompt.PromptTemplate
import com.xebia.functional.xef.vectorstores.VectorStore

class LLMAgent(
private val llm: OpenAIClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.auto
package com.xebia.functional.xef.auto

import arrow.core.Either
import arrow.core.left
Expand All @@ -7,16 +7,18 @@ import arrow.core.raise.recover
import arrow.core.right
import arrow.fx.coroutines.ResourceScope
import arrow.fx.coroutines.resourceScope
import com.xebia.functional.AIError
import com.xebia.functional.agents.ContextualAgent
import com.xebia.functional.agents.DeserializerLLMAgent
import com.xebia.functional.agents.LLMAgent
import com.xebia.functional.embeddings.OpenAIEmbeddings
import com.xebia.functional.env.OpenAIConfig
import com.xebia.functional.llm.openai.*
import com.xebia.functional.prompt.PromptTemplate
import com.xebia.functional.vectorstores.LocalVectorStore
import com.xebia.functional.vectorstores.VectorStore
import com.xebia.functional.xef.AIError
import com.xebia.functional.xef.agents.ContextualAgent
import com.xebia.functional.xef.agents.DeserializerLLMAgent
import com.xebia.functional.xef.agents.LLMAgent
import com.xebia.functional.xef.embeddings.OpenAIEmbeddings
import com.xebia.functional.xef.env.OpenAIConfig
import com.xebia.functional.xef.llm.openai.KtorOpenAIClient
import com.xebia.functional.xef.llm.openai.LLMModel
import com.xebia.functional.xef.llm.openai.OpenAIClient
import com.xebia.functional.xef.prompt.PromptTemplate
import com.xebia.functional.xef.vectorstores.LocalVectorStore
import com.xebia.functional.xef.vectorstores.VectorStore
import io.github.oshai.KLogger
import io.github.oshai.KotlinLogging
import kotlin.jvm.JvmName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.auto
package com.xebia.functional.xef.auto

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:OptIn(ExperimentalSerializationApi::class)

package com.xebia.functional.auto.serialization
package com.xebia.functional.xef.auto.serialization

/*
Ported over from https://github.com/Ricky12Awesome/json-schema-serialization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xebia.functional.embeddings
package com.xebia.functional.xef.embeddings

import com.xebia.functional.llm.openai.RequestConfig
import com.xebia.functional.xef.llm.openai.RequestConfig

data class Embedding(val data: List<Float>)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.xebia.functional.embeddings
package com.xebia.functional.xef.embeddings

import arrow.fx.coroutines.parMap
import arrow.resilience.retry
import com.xebia.functional.env.OpenAIConfig
import com.xebia.functional.llm.openai.EmbeddingRequest
import com.xebia.functional.llm.openai.OpenAIClient
import com.xebia.functional.llm.openai.RequestConfig
import com.xebia.functional.xef.env.OpenAIConfig
import com.xebia.functional.xef.llm.openai.EmbeddingRequest
import com.xebia.functional.xef.llm.openai.OpenAIClient
import com.xebia.functional.xef.llm.openai.RequestConfig
import io.github.oshai.KLogger
import kotlin.time.ExperimentalTime

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.xebia.functional.env
package com.xebia.functional.xef.env

import arrow.core.NonEmptyList
import arrow.core.raise.Raise
import arrow.core.raise.catch
import arrow.core.raise.recover
import arrow.core.raise.zipOrAccumulate
import arrow.resilience.Schedule
import com.xebia.functional.AIError
import com.xebia.functional.xef.AIError
import io.ktor.http.Url as KUrl
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.env
package com.xebia.functional.xef.env

import arrow.core.raise.Raise
import arrow.core.raise.ensureNotNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional
package com.xebia.functional.xef

import arrow.fx.coroutines.ResourceScope
import io.ktor.client.HttpClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.xebia.functional.llm.huggingface
package com.xebia.functional.xef.llm.huggingface

import arrow.fx.coroutines.ResourceScope
import com.xebia.functional.configure
import com.xebia.functional.env.HuggingFaceConfig
import com.xebia.functional.httpClient
import com.xebia.functional.xef.configure
import com.xebia.functional.xef.env.HuggingFaceConfig
import com.xebia.functional.xef.httpClient
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.engine.HttpClientEngine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.llm.huggingface
package com.xebia.functional.xef.llm.huggingface

import kotlin.jvm.JvmInline
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.xebia.functional.llm.openai
package com.xebia.functional.xef.llm.openai

import arrow.fx.coroutines.ResourceScope
import arrow.resilience.retry
import com.xebia.functional.configure
import com.xebia.functional.env.OpenAIConfig
import com.xebia.functional.httpClient
import com.xebia.functional.xef.configure
import com.xebia.functional.xef.env.OpenAIConfig
import com.xebia.functional.xef.httpClient
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.engine.HttpClientEngine
Expand All @@ -21,7 +21,8 @@ interface OpenAIClient {
suspend fun ResourceScope.KtorOpenAIClient(
config: OpenAIConfig,
engine: HttpClientEngine? = null
): OpenAIClient = KtorOpenAIClient(httpClient(engine, config.baseUrl), config)
): OpenAIClient =
com.xebia.functional.xef.llm.openai.KtorOpenAIClient(httpClient(engine, config.baseUrl), config)

private class KtorOpenAIClient(
private val httpClient: HttpClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.llm.openai
package com.xebia.functional.xef.llm.openai

import kotlin.jvm.JvmInline
import kotlinx.serialization.SerialName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xebia.functional.loaders
package com.xebia.functional.xef.loaders

import com.xebia.functional.textsplitters.BaseTextSplitter
import com.xebia.functional.xef.textsplitters.BaseTextSplitter

interface BaseLoader {
suspend fun load(): List<String>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.xebia.functional
package com.xebia.functional.xef

import arrow.core.raise.either
import arrow.fx.coroutines.resourceScope
import com.xebia.functional.env.Env
import com.xebia.functional.llm.huggingface.HuggingFaceClient
import com.xebia.functional.llm.huggingface.InferenceRequest
import com.xebia.functional.llm.huggingface.KtorHuggingFaceClient
import com.xebia.functional.llm.huggingface.Model
import com.xebia.functional.llm.openai.CompletionRequest
import com.xebia.functional.llm.openai.EmbeddingRequest
import com.xebia.functional.llm.openai.KtorOpenAIClient
import com.xebia.functional.llm.openai.OpenAIClient
import com.xebia.functional.xef.env.Env
import com.xebia.functional.xef.llm.huggingface.HuggingFaceClient
import com.xebia.functional.xef.llm.huggingface.InferenceRequest
import com.xebia.functional.xef.llm.huggingface.KtorHuggingFaceClient
import com.xebia.functional.xef.llm.huggingface.Model
import com.xebia.functional.xef.llm.openai.CompletionRequest
import com.xebia.functional.xef.llm.openai.EmbeddingRequest
import com.xebia.functional.xef.llm.openai.KtorOpenAIClient
import com.xebia.functional.xef.llm.openai.OpenAIClient

suspend fun main(): Unit = resourceScope {
either {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.prompt
package com.xebia.functional.xef.prompt

import arrow.core.raise.Raise
import arrow.core.raise.either
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.prompt
package com.xebia.functional.xef.prompt

import arrow.core.Either
import arrow.core.NonEmptyList
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.textsplitters
package com.xebia.functional.xef.textsplitters

interface BaseTextSplitter {
suspend fun splitText(text: String): List<String>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xebia.functional.textsplitters
package com.xebia.functional.xef.textsplitters

fun CharacterTextSplitter(separator: String): BaseTextSplitter =
object : BaseTextSplitter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.xebia.functional.vectorstores
package com.xebia.functional.xef.vectorstores

import arrow.fx.stm.TMap
import arrow.fx.stm.TVar
import arrow.fx.stm.atomically
import com.xebia.functional.embeddings.Embedding
import com.xebia.functional.embeddings.Embeddings
import com.xebia.functional.llm.openai.EmbeddingModel
import com.xebia.functional.llm.openai.RequestConfig
import com.xebia.functional.xef.embeddings.Embedding
import com.xebia.functional.xef.embeddings.Embeddings
import com.xebia.functional.xef.llm.openai.EmbeddingModel
import com.xebia.functional.xef.llm.openai.RequestConfig
import kotlin.math.sqrt

class LocalVectorStore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.xebia.functional.vectorstores
package com.xebia.functional.xef.vectorstores

import com.xebia.functional.embeddings.Embedding
import com.xebia.functional.xef.embeddings.Embedding

interface VectorStore {
/**
Expand Down
Loading