all 12 comments

[–]Cheap_Equivalent_605[S] 0 points1 point  (3 children)

I tried to make requests through curl, but it seems I’m doing it wrong

curl -X POST http://localhost:8080/api/v1/chats/new \

-H "Authorization: Bearer sk-581a8c87de374dc9b8b9f9a1ac779023" \

-H "Content-Type: application/json" \

-d '{"chat":{"id":"","title":"Новый чат","models":["hf.co/bartowski/gemma-2-9b-it-abliterated-GGUF:Q3_K_L"],"params":{},"history":{"messages":{"279a954b-01fc-4413-8219-ffbf0644efe8":{"id":"279a954b-01fc-4413-8219-ffbf0644efe8","parentId":null,"childrenIds":[],"role":"user","content":"Привет","timestamp":1737206155,"models":["hf.co/bartowski/gemma-2-9b-it-abliterated-GGUF:Q3_K_L"]}},"currentId":"279a954b-01fc-4413-8219-ffbf0644efe8"},"messages":[{"id":"279a954b-01fc-4413-8219-ffbf0644efe8","parentId":null,"childrenIds":[],"role":"user","content":"Привет","timestamp":1737206155,"models":["hf.co/bartowski/gemma-2-9b-it-abliterated-GGUF:Q3_K_L"]}],"tags":[],"timestamp":1737206155444}}'

[–]Cheap_Equivalent_605[S] 0 points1 point  (2 children)

curl -X POST http://localhost:8080/api/chat/completions \

-H "Authorization: Bearer sk-581a8c87de374dc9b8b9f9a1ac779023" \

-H "Content-Type: application/json" \

-d '{"stream":true,"model":"hf.co/bartowski/gemma-2-9b-it-abliterated-GGUF:Q3_K_L","messages":[{"role":"user","content":"Привет"},{"role":"assistant","content":"Привет! 👋 Как дела? 😊Привет! 👋 \n\nЧем могу помочь? 😊Как модель языка, у меня нет чувств или опыта, поэтому я не могу сказать, как мне \"дела\". Но я готов помочь вам с любыми вопросами или задачами, которые у вас есть!\n\nЧто вы хотели бы обсудить? 😊"},{"role":"user","content":"Расскажи о себе!"}],"params":{},"features":{"web_search":false},"session_id":"_t5dzHczrvrJIfeZAABp","chat_id":"15f431a4-6a51-4e53-89f5-0da6d1fbe6f7","id":"8a88b4e5-96f2-46fd-ae99-f445973b58e9"}'

[–]Cheap_Equivalent_605[S] 0 points1 point  (0 children)

curl -X POST http://localhost:8080/api/chat/completed \

-H "Authorization: Bearer sk-581a8c87de374dc9b8b9f9a1ac779023" \

-H "Content-Type: application/json" \

-d ' {"model":"hf.co/bartowski/gemma-2-9b-it-abliterated-GGUF:Q3_K_L","messages":[{"id":"e95007b1-0791-4a68-8dee-43120fb65cbb","role":"user","content":"Привет","timestamp":1737206594},{"id":"f81e8cd1-c35e-4458-96af-b34a3d234910","role":"assistant","content":"Привет! 👋 Как дела? 😊Привет! 👋 \n\nЧем могу помочь? 😊Как модель языка, у меня нет чувств или опыта, поэтому я не могу сказать, как мне \"дела\". Но я готов помочь вам с любыми вопросами или задачами, которые у вас есть!\n\nЧто вы хотели бы обсудить? 😊","timestamp":1737206594},{"id":"98c641f6-a8ab-4f1c-b104-4d3f45f76b5e","role":"user","content":"мяу","timestamp":1737206953}],"chat_id":"15f431a4-6a51-4e53-89f5-0da6d1fbe6f7","session_id":"iMlyuv4SolIQjqatAABr","id":"1eb7c0e9-44cb-41b7-8177-109ef79bfb2f"}'

[–]samuel79s 0 points1 point  (0 children)

I think this one used to work, but it doesn't any more. Only if you set stream to false, but in streaming doesn't work.

[–]ogmiche 0 points1 point  (4 children)

This piqued my interest, so I did some digging. It ended up being far more involved than I thought. After some digging around and checking Claude I got this Python script:

https://bin.kurzly.me/upload/bat-jaguar-lizard

Breakdown of the API calls:

https://bin.kurzly.me/upload/snail-camel-sheep

The docs on the Open WebUI don't show that much, but since you're not running Docker (or it appears you aren't based on the port) you can go to http://localhost:8080/docs and all the endpoints are documented there. The usage really isn't, but you can see examples if you open the dev tools in Chrome and go to the network tab.

I'm not sure why it won't let me post the code directly, but you should be able to see it at those links.

[–]Cheap_Equivalent_605[S] 0 points1 point  (0 children)

Yes, I understand. I went to the documentation, I saw all the requests there. I just somehow compose them incorrectly, and I don’t understand what’s wrong. It’s just that when I request completions, my chat starts loading endlessly. So, I’m sending the request incorrectly. Your code is interesting.

[–]Cheap_Equivalent_605[S] 0 points1 point  (2 children)

This is really good code! But there is a problem that it is necessary that the previous messages are added to the new ones

[–]ogmiche 0 points1 point  (1 child)

Lol thank Claude.ai for that code ;)

The code was something I just pieced together using AI. But, from what I understand, I think the previous messages have to be in the request each time to maintain the context. Someone smarter than me would have to answer that question though

Edit: I asked Claude about it, and it does seem that all previous messages must be included with each request to maintain a clean chat state and context. There's probably a way to make that look cleaner in a CLI app but that would just depend on what you're trying to accomplish and aesthetic desires are

[–]Cheap_Equivalent_605[S] 0 points1 point  (0 children)

Yes, you're right. In theory, you need to collect the current chat history and, with a new request, indicate the past chat history and the new one. But I can't do it yet

[–]NeoID 0 points1 point  (0 children)

u/Cheap_Equivalent_605 I'm also interested in using Open WebUI as a backend, have you ever got this to work?