...
This commit is contained in:
@@ -5,25 +5,24 @@ module main
|
||||
import freeflowuniverse.herolib.clients.openai
|
||||
import os
|
||||
|
||||
|
||||
fn test1(mut client openai.OpenAI)!{
|
||||
|
||||
|
||||
instruction:='
|
||||
fn test1(mut client openai.OpenAI) ! {
|
||||
instruction := '
|
||||
You are a template language converter. You convert Pug templates to Jet templates.
|
||||
|
||||
The target template language, Jet, is defined as follows:
|
||||
'
|
||||
|
||||
// Create a chat completion request
|
||||
res := client.chat_completion(msgs:openai.Messages{
|
||||
messages: [
|
||||
openai.Message{
|
||||
role: .user
|
||||
content: 'What are the key differences between Groq and other AI inference providers?'
|
||||
},
|
||||
]
|
||||
})!
|
||||
res := client.chat_completion(
|
||||
msgs: openai.Messages{
|
||||
messages: [
|
||||
openai.Message{
|
||||
role: .user
|
||||
content: 'What are the key differences between Groq and other AI inference providers?'
|
||||
},
|
||||
]
|
||||
}
|
||||
)!
|
||||
|
||||
// Print the response
|
||||
println('\nGroq AI Response:')
|
||||
@@ -33,23 +32,21 @@ fn test1(mut client openai.OpenAI)!{
|
||||
println('Prompt tokens: ${res.usage.prompt_tokens}')
|
||||
println('Completion tokens: ${res.usage.completion_tokens}')
|
||||
println('Total tokens: ${res.usage.total_tokens}')
|
||||
|
||||
}
|
||||
|
||||
|
||||
fn test2(mut client openai.OpenAI)!{
|
||||
|
||||
fn test2(mut client openai.OpenAI) ! {
|
||||
// Create a chat completion request
|
||||
res := client.chat_completion(
|
||||
model:"deepseek-r1-distill-llama-70b",
|
||||
msgs:openai.Messages{
|
||||
messages: [
|
||||
openai.Message{
|
||||
role: .user
|
||||
content: 'A story of 10 lines?'
|
||||
},
|
||||
]
|
||||
})!
|
||||
model: 'deepseek-r1-distill-llama-70b'
|
||||
msgs: openai.Messages{
|
||||
messages: [
|
||||
openai.Message{
|
||||
role: .user
|
||||
content: 'A story of 10 lines?'
|
||||
},
|
||||
]
|
||||
}
|
||||
)!
|
||||
|
||||
println('\nGroq AI Response:')
|
||||
println('==================')
|
||||
@@ -57,21 +54,18 @@ fn test2(mut client openai.OpenAI)!{
|
||||
println('\nUsage Statistics:')
|
||||
println('Prompt tokens: ${res.usage.prompt_tokens}')
|
||||
println('Completion tokens: ${res.usage.completion_tokens}')
|
||||
println('Total tokens: ${res.usage.total_tokens}')
|
||||
|
||||
println('Total tokens: ${res.usage.total_tokens}')
|
||||
}
|
||||
|
||||
|
||||
println('
|
||||
println("
|
||||
TO USE:
|
||||
export AIKEY=\'gsk_...\'
|
||||
export AIURL=\'https://api.groq.com/openai/v1\'
|
||||
export AIMODEL=\'llama-3.3-70b-versatile\'
|
||||
')
|
||||
export AIKEY='gsk_...'
|
||||
export AIURL='https://api.groq.com/openai/v1'
|
||||
export AIMODEL='llama-3.3-70b-versatile'
|
||||
")
|
||||
|
||||
mut client:=openai.get(name:"test")!
|
||||
mut client := openai.get(name: 'test')!
|
||||
println(client)
|
||||
|
||||
|
||||
// test1(mut client)!
|
||||
test2(mut client)!
|
||||
|
||||
Reference in New Issue
Block a user