Skip to content

Commit

Permalink
[RFC] Add "function" as an explicit kind of output data (#628)
Browse files Browse the repository at this point in the history
[RFC] Add "function" as an explicit kind of output data

This can help us distinguish function calling from regular strings
quickly -- since function calling is now supported across multiple
models, it deserves to be a top-level output kind in the schema.

For example, current models that support it:
* GPT-3.5, GPT-4, GPT-4V
* Gemini
* [Mixtral (using Anyscale
endpoints)](https://docs.endpoints.anyscale.com/guides/function-calling/#:~:text=With%20Anyscale%20Endpoints%2C%20you%20can,parameters%20to%20pass%20to%20it.)
* There will be more to come
  • Loading branch information
saqadri authored Dec 27, 2023
2 parents 13933c9 + d3fdc77 commit fefe6e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions python/src/aiconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ class OutputData(BaseModel):
value: str


class FunctionCallData(BaseModel):
"""
Function call data reprsenting a single function call
"""

name: str
arguments: str

class Config:
extra = "allow"


class FunctionCall(BaseModel):
"""
Standard format for data representing function call(s)
"""

kind: Literal["function"]
value: List[FunctionCallData]


class ExecuteResult(BaseModel):
"""
ExecuteResult represents the result of executing a prompt.
Expand Down
8 changes: 8 additions & 0 deletions typescript/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ export type ExecuteResult = {
| {
kind: "string" | "file_uri" | "base64";
value: string;
}
| {
kind: "function";
value: {
name: string;
arguments: string;
[k: string]: any;
}[];
};
/**
* The MIME type of the result. If not specified, the MIME type will be assumed to be plain text.
Expand Down

0 comments on commit fefe6e6

Please sign in to comment.