Merge branch 'main_openai_fixes' into development_actions

* main_openai_fixes:
  wip: add tests for openai client
  fix crystallib imports
  fixes in openai client

# Conflicts:
#	examples/hero/generation/openapi_generation/example_actor/actor.v
#	examples/hero/openapi/actor.vsh
#	examples/hero/openapi/server.vsh
This commit is contained in:
2024-12-31 10:23:20 +01:00
27 changed files with 787 additions and 353 deletions

View File

@@ -26,9 +26,9 @@ pub fn run() ! {
pub fn run_server(params RunParams) ! {
mut a := new()!
mut server := actor.new_server(
redis_url: 'localhost:6379'
redis_queue: a.name
openapi_spec: openapi_specification
redis_url: 'localhost:6379'
redis_queue: a.name
openapi_spec: example_actor.openapi_specification
)!
server.run(params)
}

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -w -n -enable-globals run
import os
import time
@@ -52,7 +52,7 @@ fn main() {
mut rpc := redis.rpc_get('procedure_queue')
mut actor := Actor{
rpc: rpc
rpc: rpc
data_store: DataStore{}
}
@@ -172,9 +172,9 @@ fn (mut store DataStore) list_pets(params ListPetParams) []Pet {
fn (mut store DataStore) create_pet(new_pet NewPet) Pet {
id := store.pets.keys().len + 1
pet := Pet{
id: id
id: id
name: new_pet.name
tag: new_pet.tag
tag: new_pet.tag
}
store.pets[id] = pet
return pet
@@ -211,10 +211,10 @@ fn (mut store DataStore) delete_order(id int) ! {
fn (mut store DataStore) create_user(new_user NewUser) User {
id := store.users.keys().len + 1
user := User{
id: id
id: id
username: new_user.username
email: new_user.email
phone: new_user.phone
email: new_user.email
phone: new_user.phone
}
store.users[id] = user
return user

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -w -n -enable-globals run
import os
import time
@@ -23,7 +23,7 @@ fn main() {
// Initialize the server
mut server := &Server{
specification: openapi.json_decode(spec_json)!
handler: Handler{
handler: Handler{
processor: Processor{
rpc: rpc
}
@@ -122,7 +122,7 @@ fn (mut handler Handler) handle(request Request) !Response {
if err is processor.ProcedureError {
return Response{
status: http.status_from_int(err.code()) // Map ProcedureError reason to HTTP status code
body: json.encode({
body: json.encode({
'error': err.msg()
})
}
@@ -133,6 +133,6 @@ fn (mut handler Handler) handle(request Request) !Response {
// Convert returned procedure response to OpenAPI response
return Response{
status: http.Status.ok // Assuming success if no error
body: procedure_response.result
body: procedure_response.result
}
}