alpaca.cpp icon indicating copy to clipboard operation
alpaca.cpp copied to clipboard

Can this be interacted with in API-like request way?

Open tjthejuggler opened this issue 1 year ago • 15 comments

I want to be able to send individual requests from a separate program to an instance of Alpaca running just like can be done with the OpenAI API. Is this currently possible?

tjthejuggler avatar Mar 20 '23 18:03 tjthejuggler

+1, Also with this maybe we could keep track of the old conversations and feed them to Alpaca, so that context becomes better

pete02 avatar Mar 20 '23 18:03 pete02

This is my current way to call it from the simulated terminal (node-pty)

https://github.com/linonetwo/langchain-alpaca/blob/1c519c206ea5152269c3d82d160a2567bbc9e69f/src/index.ts#L222-L282

I also hope there can be a way to deep integrate it, so it won't need to restart on every request!

linonetwo avatar Mar 20 '23 18:03 linonetwo

+1 REST API would be helpful.

sungkim11 avatar Mar 20 '23 19:03 sungkim11

+1 I'm a beginner and I've been trying to use python to call "chat.exe" using the subprocesses library but it doesn't seem to be working. I want to be able to make it remember convos and then make it voice activated using python.

anm5704 avatar Mar 20 '23 19:03 anm5704

Agree, even simple non-interactive way to communicate for example trough files or pipes would be nice.

kawashirov avatar Mar 21 '23 00:03 kawashirov

Yes, or maybe simple tcp socket

Solexid avatar Mar 21 '23 00:03 Solexid

I feel I might help, I'm playing with alpaca.cpp here to have it with an API, more or less openAI style: https://github.com/go-skynet/llama-cli and seems to work, happy to contribute it somewhere else. I just really wanted to have it programmatically accessible via pipes/API to use it for automation.

mudler avatar Mar 21 '23 00:03 mudler

@mudler Can you explain how did you keep it running, so we can port this technique to Py and TS in LangChain.

I guess you keep interaction mode running in memory, and reuse the instance? That is what I want to try next.

linonetwo avatar Mar 21 '23 03:03 linonetwo

@mudler Can you explain how did you keep it running, so we can port this technique to Py and TS in LangChain.

Sure thing, I've slightly modified the original lama.cpp to keep the result in memory and return it back, code with golang bindings it's here: https://github.com/go-skynet/llama

I guess you keep interaction mode running in memory, and reuse the instance? That is what I want to try next.

yup correct, I actually pruned the interactive code completely to keep it simpler

mudler avatar Mar 21 '23 07:03 mudler

I feel I might help, I'm playing with alpaca.cpp here to have it with an API, more or less openAI style: https://github.com/go-skynet/llama-cli and seems to work, happy to contribute it somewhere else. I just really wanted to have it programmatically accessible via pipes/API to use it for automation.

does your code work on llama.cpp, isn't that different from the fine tuned alpaca model?

anm5704 avatar Mar 21 '23 07:03 anm5704

I feel I might help, I'm playing with alpaca.cpp here to have it with an API, more or less openAI style: https://github.com/go-skynet/llama-cli and seems to work, happy to contribute it somewhere else. I just really wanted to have it programmatically accessible via pipes/API to use it for automation.

does your code work on llama.cpp, isn't that different from the fine tuned alpaca model?

When doing this I've walked the changes with alpaca.cpp too, so should be compatible, I've actually tried it only with alpaca models as I don't have bigger hardware to test it with. Also it is on pair with the original lama.cpp which supports alpaca.

Update: I've managed to run also 13b and 30b alpaca models with the new tokenizer, will update later today

mudler avatar Mar 21 '23 07:03 mudler

Implemented this relatively simple python-based solution if that's helpful to anyone: https://github.com/muelletm/alpaca.py.

muelletm avatar Mar 25 '23 23:03 muelletm

@muelletm I tried it. At first, it gave me JSON Decode Error. Then I did a try-catch. After that, the code just stops completely.

robin-coac avatar Mar 31 '23 19:03 robin-coac

@robin-coac Can you open an issue in https://github.com/muelletm/alpaca.py and share how you start the API and how you call it?

muelletm avatar Mar 31 '23 19:03 muelletm

Hi @muelletm I create an issue.

robin-coac avatar Apr 01 '23 06:04 robin-coac