ChatGpt

io.github.quafadas.dairect.ChatGpt
See theChatGpt companion trait
object ChatGpt

Attributes

Companion
trait
Experimental
true
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ChatGpt.type

Members list

Type members

Classlikes

case class AiAnswer(role: String, content: Option[String], tool_calls: Option[List[ToolCall]])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class AiChoice(message: AiAnswer, finish_reason: Option[String])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class AiMessage(role: String, content: Option[String], tool_calls: Option[List[ToolCall]], tool_call_id: Option[String], name: Option[String])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object AiMessage

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
AiMessage.type
case class AiTokenUsage(completion_tokens: Int, prompt_tokens: Int, total_tokens: Int)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ChatCompletionFunctions(name: String, parameters: Document, description: Option[String])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ChatCompletionResponseMessage(role: String, content: Option[String], function_call: Option[ChatCompletionResponseMessageFunctionCall])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ChatCompletionResponseMessageFunctionCall(name: Option[String], arguments: Option[String])

The name and arguments of a function that should be called, as generated by the model.

The name and arguments of a function that should be called, as generated by the model.

Value parameters

arguments

The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.

name

The name of the function to call.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ChatGptConfig(model: String, temperature: Option[Double], responseFormat: Option[AiResponseFormat])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ChatResponse(id: String, created: Int, model: String, choices: List[AiChoice], usage: AiTokenUsage)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def apply(client: Client[IO], baseUrl: Uri): Resource[IO, ChatGpt]

Value parameters

baseUrl

- The base url of the openAi service see ChatGpt

client

- An http4s client - apply your middleware to it

Attributes

def defaultAuthLogToFile(logPath: Path, provided: Resource[IO, Client[IO]]): Resource[IO, ChatGpt]

It is assumed, that an environment variable OPEN_AI_API_TOKEN is set with a valid token, to openai's api. This agent will write all in and outgoing messages to the file specified (no headers).

It is assumed, that an environment variable OPEN_AI_API_TOKEN is set with a valid token, to openai's api. This agent will write all in and outgoing messages to the file specified (no headers).

It ought to be rather easy to customize this to your needs by:

  • changing the logPath to a different path ( per agent perhaps )
  • using a different URL (if your corp wraps the endpoint seperately)
  • Adding other http4s client middleware

Value parameters

logPath

- The path to the log file

Attributes

Givens

Givens

given derived$API: API[ChatGpt]

Extensions

Extensions

extension (aic: AiChoice)
def toMessage: List[AiMessage]