Closed sullrich closed 9 months ago
Hey welcome! What command did you run to start the API?
Did you run make all
? Maybe you didn't run the executor
(still figuring out the name to call it, the process that consume Redis queue to do LLM calls etc.)
I ran make docker and make server. Running make all I can see it fire up! Excellent! Thanks so much!
Once I dropped in my app, seeing this:
[2023-12-19T21:11:08Z INFO assistants_core::runs] Running assistant_id: 608f0c79-a78a-48e0-8523-75a56c2ff55b for thread_id: 028f7171-3bde-4807-87ea-8a7cd06f86c3 [2023-12-19T21:11:08Z INFO assistants_core::runs] Creating run for assistant_id: 608f0c79-a78a-48e0-8523-75a56c2ff55b Failed to create run in database: error returned from database: insert or update on table "runs" violates foreign key constraint "runs_assistant_id_fkey" [2023-12-19T21:11:08Z ERROR tower_http::trace::on_failure] response failed classification=Status code: 500 Internal Server Error latency=1 ms
This works for OpenAI OK. Any ideas?
What exactly did you do, which requests/code? Seems like you tried to create a run for a non existing assistant
Ahh, yes! Somehow the assistant I created earlier disappeared. Does the database reset after stopping and running again?
Yeah the make reboot
clean up the db. Check the Makefile to just run the DB, not cleaning up
Thanks for that! Using go + https://github.com/sashabaranov/go-openai getting this backtrace when creating an assistant:
assistantReq := openai.AssistantRequest{Model: "gpt-4-1106-preview"}
assistant, err := client.CreateAssistant(ctx, assistantReq)
called as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
7: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.29/src/future/future/map.rs:55:37
8: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.29/src/lib.rs:91:13
9: <axum::handler::future::IntoServiceFuture as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
17: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
18: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
19: as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
38: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
39: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
40: <tower_http::limit::future::ResponseFuture as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
60: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
61: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
62: <tower_http::trace::future::ResponseFuture<Fut,C,OnResponseT,OnBodyChunkT,OnEosT,OnFailureT> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.4.4/src/trace/future.rs:52:43
63: as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
82: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
83: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
84: <tower_http::cors::ResponseFuture as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
7: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.29/src/future/future/map.rs:55:37
8: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.29/src/lib.rs:91:13
9: <axum::handler::future::IntoServiceFuture as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
17: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
18: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
19: as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
38: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
39: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
40: <tower_http::limit::future::ResponseFuture as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
60: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
61: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
62: <tower_http::trace::future::ResponseFuture<Fut,C,OnResponseT,OnBodyChunkT,OnEosT,OnFailureT> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.4.4/src/trace/future.rs:52:43
63: as core::future::future::Future>::poll
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/future/future.rs:125:9
82: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-0.4.13/src/util/oneshot.rs:97:38
83: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.6.20/src/routing/route.rs:161:61
84: <tower_http::cors::ResponseFuture Does anything stick out? Option::unwrap()
on a None
value
stack backtrace:
0: rust_begin_unwind
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
1: core::panicking::panic_fmt
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
2: core::panicking::panic
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:127:5
3: core::option::OptionRUST_BACKTRACE=full
for a verbose backtrace.
thread 'tokio-runtime-worker' panicked at /home/sullrich/assistants/assistants-api-communication/src/assistants.rs:21:47:
called Option::unwrap()
on a None
value
stack backtrace:
0: rust_begin_unwind
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
1: core::panicking::panic_fmt
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
2: core::panicking::panic
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:127:5
3: core::option::OptionRUST_BACKTRACE=full
for a verbose backtrace.
This was due to missing Tools and other vars: Model: "gpt-4-1106-preview", Name: &assistantName, Description: &assistantDescription, Instructions: &assistantInstructions, Tools: tools,
Afterwards seeing (but I did set the key):
thread 'main' panicked at /home/sullrich/assistants/assistants-extra/src/openai.rs:255:51:
OPENAI_API_KEY must be set: NotPresent
stack backtrace:
0: rust_begin_unwind
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
1: core::panicking::panic_fmt
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/result.rs:1652:5
3: core::result::Result<T,E>::expect
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/result.rs:1034:23
4: assistants_extra::openai::call_openai_api_with_messages::{{closure}}
at ./assistants-extra/src/openai.rs:255:19
5: assistants_extra::llm::llm::{{closure}}
at ./assistants-extra/src/llm.rs:64:10
6: assistants_core::assistant::decide_tool_with_llm::{{closure}}
at ./assistants-core/src/assistant.rs:268:6
7: assistants_core::assistant::queue_consumer::{{closure}}
at ./assistants-core/src/assistant.rs:396:70
8: run_consumer::main::{{closure}}
at ./assistants-core/src/bin/run_consumer.rs:61:41
9: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/park.rs:282:63
10: tokio::runtime::coop::with_budget
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/coop.rs:107:5
11: tokio::runtime::coop::budget
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/coop.rs:73:5
12: tokio::runtime::park::CachedParkThread::block_on
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/park.rs:282:31
13: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/context/blocking.rs:66:9
14: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
15: tokio::runtime::context::runtime::enter_runtime
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/context/runtime.rs:65:16
16: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
17: tokio::runtime::runtime::Runtime::block_on
at /home/sullrich/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.0/src/runtime/runtime.rs:350:45
18: run_consumer::main
at ./assistants-core/src/bin/run_consumer.rs:60:5
19: core::ops::function::FnOnce::call_once
at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with RUST_BACKTRACE=full
for a verbose backtrace.
thx just fixed the no tools use case!
how did you set the openai api key?
Am setting the API Key via the OpenAI client. The fix for tools worked! It created the assistant OK but then I reach:
[2023-12-20T13:03:34Z INFO assistants_core::assistants] Creating assistant: Assistant { inner: AssistantObject { id: "", object: "", created_at: 0, name: Some("My GPT-4 Assistant"), description: None, model: "gpt-4-1106-preview", instructions: Some("Capable of responding to various queries."), tools: [], file_ids: [], metadata: None }, user_id: "00000000-0000-0000-0000-000000000000" } [2023-12-20T13:03:34Z INFO assistants_core::messages] Adding message to thread_id: d746ea83-f42f-4d8e-a00b-a77d347268a4, role: User, user_id: 00000000-0000-0000-0000-000000000000 [2023-12-20T13:03:34Z ERROR tower_http::trace::on_failure] response failed classification=Status code: 500 Internal Server Error latency=2 ms
Interesting I guess I could pass the client api key to server but normally you should give the api key to server through .env
Regarding this error I need more context to understand the problem
Actively working on improving the error logging and error returned to client
Can you pass api key in .env and restart your workflow from scratch?
Thats the interesting thing here, I am not actually using openai in this case. My chat client supports OpenAI and local LLM which is what I am wiring up now. I'll wait for some enhanced logging and dive back in soon!
If you create your assistant with gpt-4-1106-preview
it will use openai
I am setting the model to MODEL_URL="http://10.0.250.161:8080/v1/chat/completions" Should I leave the model blank when creating assistant or pass it the URL above?
if you are running a LLM on this IP it's good then you need to pass the model name like
const assistant = await openai.beta.assistants.create({
instructions: "You are a weather bot. Use the provided functions to answer questions.",
model: "mistralai/mixtral-8x7b-instruct",
name: "Weather Bot",
tools: [{
"type": "function",
"function": {
"name": "getCurrentWeather",
"description": "Get the weather in location",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string", "description": "The city and state e.g. San Francisco, CA" },
"unit": { "type": "string" }
},
"required": ["location"]
}
}
}]
});
console.log(JSON.stringify(assistant, null, 2));
thanks for all the feedback!
i'll try to make this more clear
Happy new year! I am getting back into this project and was able to get further into the process but hitting a blocker on the OPENAI side (I am using a local LLM and not OPENAI in this case):
2024-01-02T19:33:11Z ERROR assistants_extra::llm] Error calling OpenAI API: Deserialization Error: missing field id
at line 8 column 1
[2024-01-02T19:33:11Z ERROR assistants_core::executor] Run error: Failed to decide tool: Deserialization Error: missing field id
at line 8 column 1
[2024-01-02T19:33:11Z INFO assistants_core::runs] Updating run for run_id: f4bda353-a0a6-4fc8-8cf5-ea03acac0092
[2024-01-02T19:33:11Z ERROR assistants_core::executor] Error: Failed to decide tool: Deserialization Error: missing field id
at line 8 column 1
[2024-01-02T19:33:11Z INFO assistants_core::executor] Consuming queue
[2024-01-02T19:33:13Z INFO assistants_core::runs] Getting run from database for thread_id: ac0c211b-feae-42a1-815f-7d8fcbea00b7 and run_id: f4bda353-a0a6-4fc8-8cf5-ea03acac0092
My .env:
MODEL_URL="http://10.0.250.174:8080/completion" OPENAI_API_KEY="" MODEL_API_KEY="get it here https://docs.perplexity.ai/docs" DATABASE_URL=postgres://postgres:secret@localhost:5432/mydatabase REDIS_URL=redis://127.0.0.1/ S3_ENDPOINT=http://localhost:9000 S3_ACCESS_KEY=minioadmin S3_SECRET_KEY=minioadmin S3_BUCKET_NAME=mybucket
Since I am using a local LLM it is not requiring a key. Any guidance would be extremely appreciated!
@sullrich can you share how you run the LLM (cli ran) and the server? (Also feel free to use code blocks to make it easier to read)
my guesses, the id
is a property usually returned by OpenAI API-like Chat Completion, so the problem is either:
curl http://10.0.250.174:8080/completion \
-H "Content-Type: application/json" \
-d '{
"model": "mistralai/mixtralabcd",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
Which should return a [Chat Completion](https://platform.openai.com/docs/api-reference/chat/object)
2. the `.env` is not properly loaded by the server ("Error calling OpenAI API" is only called when you use OpenAI LLMs and not open source LLMs)
Examples of LLM APIs that does not support OpenAI API-like:
- ollama
- [llama.cpp server example](https://github.com/ggerganov/llama.cpp/tree/master/examples/server)
Examples of LLM APIs that does support OpenAI API-like:
- [FastChat (good if you have a mac)](https://github.com/stellar-amenities/assistants/tree/main/examples/hello-world-mistral-curl)
- [vLLM (good if you have a modern gpu)](https://docs.vllm.ai/en/latest/getting_started/quickstart.html#openai-compatible-server)
- [Perplexity API](https://github.com/stellar-amenities/assistants/tree/main/examples/hello-world-code-interpreter-mixtral-nodejs)
- Mistral API
- anyscale
- together ai
Let me know if that help!
I am using llama.cpp's openAI server. Its being called exactly like your code block. The client is the openai go client https://github.com/sashabaranov/go-openai
Please provide the CLI, code, requests, etc. you used
@sullrich no news?
Sorry I got pulled away on a different project. Unfortunately started getting different errors and I had made no changes on my end. Hopefully soon I can pull together minimal code to share with you.
Hello, I am trying to take the project for a spin with llama.cpp backend (works fine with openai client).
I ran through all of the example steps but it remains queued. Am I missing something? Appreciate any guidance that you can give!
On the assistant side: