kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
fix: pr feedback
rodzic
5274123343
commit
efc149a7b5
|
@ -1,74 +0,0 @@
|
|||
import { z } from 'zod'
|
||||
|
||||
// export type ChatMessageRole = 'user' | 'system' | 'assistant'
|
||||
export const ChatMessageRoleSchema = z.union([
|
||||
z.literal('user'),
|
||||
z.literal('system'),
|
||||
z.literal('assistant'),
|
||||
z.literal('function')
|
||||
])
|
||||
export type ChatMessageRole = z.infer<typeof ChatMessageRoleSchema>
|
||||
|
||||
export interface ChatMessageBase {
|
||||
role: ChatMessageRole
|
||||
content: string
|
||||
name?: string
|
||||
}
|
||||
|
||||
export interface ChatMessageUser extends ChatMessageBase {
|
||||
role: 'user'
|
||||
}
|
||||
|
||||
export interface ChatMessageSystem extends ChatMessageBase {
|
||||
role: 'system'
|
||||
}
|
||||
|
||||
export interface ChatMessageAssistant extends ChatMessageBase {
|
||||
role: 'assistant'
|
||||
}
|
||||
|
||||
export interface ChatMessageFunctionCall extends ChatMessageBase {
|
||||
role: 'assistant'
|
||||
function_call: FunctionCall
|
||||
}
|
||||
|
||||
export interface FunctionCall {
|
||||
name: string
|
||||
arguments: string
|
||||
}
|
||||
|
||||
export interface ChatMessageFunction extends ChatMessageBase {
|
||||
role: 'function'
|
||||
name: string
|
||||
}
|
||||
|
||||
export type ChatMessage =
|
||||
| ChatMessageUser
|
||||
| ChatMessageSystem
|
||||
| ChatMessageAssistant
|
||||
| ChatMessageFunctionCall
|
||||
| ChatMessageFunction
|
||||
|
||||
export interface FunctionDefinition {
|
||||
/**
|
||||
* The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
|
||||
*/
|
||||
name: string
|
||||
|
||||
/**
|
||||
* The description of what the function does.
|
||||
*/
|
||||
description?: string
|
||||
|
||||
/**
|
||||
* The parameters the function accepts, described as a JSON Schema object. See the [guide](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.
|
||||
*/
|
||||
parameters?: { [key: string]: any }
|
||||
}
|
||||
|
||||
export type FunctionCallOptions =
|
||||
| 'none'
|
||||
| 'auto'
|
||||
| {
|
||||
name: string
|
||||
}
|
|
@ -78,14 +78,12 @@ export class OpenAIChatModel<
|
|||
): Promise<
|
||||
types.BaseChatCompletionResponse<types.openai.ChatCompletionResponse>
|
||||
> {
|
||||
const res = await this._client.createChatCompletion({
|
||||
return this._client.createChatCompletion({
|
||||
...this._modelParams,
|
||||
model: this._model,
|
||||
messages,
|
||||
functions
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
public override clone(): OpenAIChatModel<TInput, TOutput> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import defaultKy from 'ky'
|
||||
|
||||
export const WEATHER_API_BASE_URL = 'http://api.weatherapi.com/v1'
|
||||
export const WEATHER_API_BASE_URL = 'https://api.weatherapi.com/v1'
|
||||
|
||||
interface CurrentWeatherResponse {
|
||||
current: CurrentWeather
|
||||
|
|
Ładowanie…
Reference in New Issue