forked from mudler/cogito
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllm.go
More file actions
31 lines (25 loc) · 820 Bytes
/
Copy pathllm.go
File metadata and controls
31 lines (25 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cogito
import (
"context"
"github.com/sashabaranov/go-openai"
)
// LLMUsage represents token usage information from an LLM response
type LLMUsage struct {
PromptTokens int
CompletionTokens int
TotalTokens int
}
type LLM interface {
Ask(ctx context.Context, f Fragment) (Fragment, error)
CreateChatCompletion(ctx context.Context, request openai.ChatCompletionRequest) (LLMReply, LLMUsage, error)
}
// StreamingLLM extends LLM with streaming support.
// Consumers should type-assert: if sllm, ok := llm.(StreamingLLM); ok { ... }
type StreamingLLM interface {
LLM
CreateChatCompletionStream(ctx context.Context, request openai.ChatCompletionRequest) (<-chan StreamEvent, error)
}
type LLMReply struct {
ChatCompletionResponse openai.ChatCompletionResponse
ReasoningContent string
}