Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending a message to the server and receiving a response in an external application? #30

Closed
Regular-Baf opened this issue Jun 13, 2023 · 10 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Regular-Baf
Copy link
Collaborator

I think the whole idea behind having the user's computer handle the compute for AI-powered applications is quite awesome, so I've decided to try and build a Minecraft mod around it. The application seems to host a server, but I was just wondering how to correctly send and receive ?

@louisgv
Copy link
Owner

louisgv commented Jun 13, 2023

@Regular-Baf
What language does the Minecraft mod use? The streaming server exposed by local.ai is a standard SSE completion endpoint, mirroring closely openai's API. LMK if you wanna jump on a call and we can jam on something this week.

@Regular-Baf
Copy link
Collaborator Author

I'm quite new to modding and programming in general so ChatGPT is doing the heavy lifting, but I'm writing the mod in Kotlin for Fabric. The code is all public here. I spent a few hours today and I've managed to get some basic functionality down, but the replies from the model are very hit and miss, likely a prompt template issue. I'd be down to discuss this project more, my Discord is Bafmaster#2997, or let me know if there is a better place to reach you :)

@louisgv
Copy link
Owner

louisgv commented Jun 14, 2023

@Regular-Baf friend request sent on Discord!

@FernandoFerrer
Copy link

Could you please provide an exaple call to the SSE completion endpoint? I am trying to call it using Python requests and sseclient but not able to make it work. Thanks!

@louisgv
Copy link
Owner

louisgv commented Jun 19, 2023

@FernandoFerrer it's a similar API to openai, here's the js call:

https://github.com/louisgv/local.ai/blob/main/apps/desktop/src/features/thread/use-active-thread.ts#L82-L114
https://github.com/louisgv/local.ai/blob/main/apps/desktop/src/features/thread/process-sse-stream.ts

It's a data stream /completion endpoint. Maybe you didn't include the /completion?

@FernandoFerrerTDK
Copy link

Thank you very much! Following your example I was able to make it work :)

@louisgv
Copy link
Owner

louisgv commented Jun 20, 2023

I think it would be awesome if we have a simple example python project or something like a streamlit playground for folks to quickly test out the API call.

@FernandoFerrerTDK @Regular-Baf Would you guys be down publish an example github repo project? We can then link them in our github and frontpage as well. I know that @Regular-Baf got a working Kotlin client, and I think having both as an example would be huge!

@Regular-Baf
Copy link
Collaborator Author

Maybe a wiki page on local.ai's own GitHub page would go a long way for helping with this? I'd absolutely be happy for my code to be used there as an example. This is the part of my mod which handles the API call.

@louisgv
Copy link
Owner

louisgv commented Jun 21, 2023

Just enabled wiki: https://github.com/louisgv/local.ai/wiki

@louisgv louisgv added documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jun 23, 2023
@louisgv
Copy link
Owner

louisgv commented Jul 6, 2023

@louisgv louisgv closed this as completed Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants