Skip to content

Commit

Permalink
CU-865cn6kqn Model capabilities and AIScope simplification. (#214)
Browse files Browse the repository at this point in the history
* Generic AI client and models with open-ai client impl from https://github.com/aallam/openai-kotlin

* type LLM models based on their capabilities and type the operations

* add token as parameter to `openAI` fn falling back to env variable

* add config as optional parameter

* remove old config

* adapt to latest changes from main and new java module

* have openai be its own module that depends on xef-core. kotlin, scala and java depends on openai module for defaults. xef core does not depend on open ai

* fix bug in scala fn name for serialization

* make AIClient : AutoCloseable

* Rename enum cases

* Rename to TEXT_EMBEDDING_ADA_002

* Fix AIClient close expectation

* Progress with models

* Refactor to have models typed and increase ergonomics

* Loading embeddings and tokenizer from huggingface, dynamic loading of local models. Local models can be use in the AI DSL and interleaved with any model.

* remove non used repositories

* Fix functions model to GPT_3_5_TURBO_FUNCTIONS and example without AI block and manual component construction

* remove unused import

* Small suggestions

* More small suggestions

- Replace blocks with equals / single expressions

---------

Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
Co-authored-by: Diego E. Alonso <diego.e.a@47deg.com>
  • Loading branch information
3 people authored Jul 3, 2023
1 parent c0af078 commit b1ebeea
Show file tree
Hide file tree
Showing 76 changed files with 1,111 additions and 1,023 deletions.
11 changes: 0 additions & 11 deletions core/src/commonMain/kotlin/com/xebia/functional/xef/auto/AI.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.xebia.functional.xef.auto

import com.xebia.functional.xef.AIError
import com.xebia.functional.xef.llm.AIClient
import com.xebia.functional.xef.vectorstores.VectorStore

@DslMarker annotation class AiDsl

/**
* An [AI] value represents an action relying on artificial intelligence that can be run to produce
* an `A`. This value is _lazy_ and can be combined with other `AI` values using
Expand All @@ -18,10 +14,3 @@ typealias AI<A> = suspend CoreAIScope.() -> A

/** A DSL block that makes it more convenient to construct [AI] values. */
inline fun <A> ai(noinline block: suspend CoreAIScope.() -> A): AI<A> = block

suspend fun <A> AIScope(runtime: AIRuntime<A>, block: AI<A>, orElse: suspend (AIError) -> A): A =
try {
runtime.runtime(block)
} catch (e: AIError) {
orElse(e)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.xebia.functional.xef.auto

@DslMarker annotation class AiDsl
Loading

0 comments on commit b1ebeea

Please sign in to comment.