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

Ollama provider #27

Closed
wants to merge 1 commit into from
Closed

Ollama provider #27

wants to merge 1 commit into from

Conversation

rnbwdsh
Copy link

@rnbwdsh rnbwdsh commented Apr 10, 2024

Pulls available models from /tags endpoint.

Calls /generate endpoint for generating response.

API doc: https://editor.swagger.io/?url=https://raw.githubusercontent.com/marscod/ollama/main/api/ollama_api_specification.json

TODO: tests
TODO: maybe you can use the openapi lib client? Nicer request structure?

@rnbwdsh
Copy link
Author

rnbwdsh commented Apr 16, 2024

I just realized both ollama and openrouter support the /chat syntax with List[Dict[Literal["system"|"user"|"assistant"]: str]], so that you can condition the LLM to always start with

package plain

....

So I'd rework the connector to use the /chat instead of /generate (probably try to use the same client as openrouter) and I'd split the prompt into prompts:
{"system": "you are a test engineer, and you should write tests for the code the user provides.",
"user": challenge_message,
"assistant": `

package plain

import {
  TODO
}


func`}

This would also require small modification for the runner.

@chadbrewbaker
Copy link

chadbrewbaker commented Apr 25, 2024

Can we make this a CLI provider too?

Change this so it takes a constructor that has the command line string to shell out to. Should support ollama cli, llm cli ... that saves all the network headache.

func (p *ollamaQueryProvider) Query(ctx context.Context, modelIdentifier string, promptText string) (response string, err error) {

For testing I would just mostly mock, but you could roll the Shakespeare mini llm for integration tests. https://github.com/ggerganov/llama.cpp/blob/master/examples/train-text-from-scratch/README.md

@zimmski zimmski added this to the v0.5.0 milestone Apr 26, 2024
@zimmski zimmski added the enhancement New feature or request label Apr 26, 2024
@zimmski zimmski self-requested a review April 26, 2024 13:14
@bauersimon bauersimon mentioned this pull request May 6, 2024
10 tasks
This was referenced May 14, 2024
@zimmski zimmski closed this May 16, 2024
@zimmski
Copy link
Member

zimmski commented May 16, 2024

@rnbwdsh thanks for the PR! We have now merged all the bits and pieces, and quite some changes were necessary to get this working, tested and integrated. We did not do the automatic installation for Windows/MacOS. So if you want to add that, that would be great! Can guide you through. We are adding documentation soonish, and then a tutorial + video in the coming days.

@zimmski
Copy link
Member

zimmski commented May 16, 2024

I just realized both ollama and openrouter support the /chat syntax with List[Dict[Literal["system"|"user"|"assistant"]: str]], so that you can condition the LLM to always start with

package plain

....

So I'd rework the connector to use the /chat instead of /generate (probably try to use the same client as openrouter) and I'd split the prompt into prompts: {"system": "you are a test engineer, and you should write tests for the code the user provides.", "user": challenge_message, "assistant": `

package plain

import {
  TODO
}


func`}

This would also require small modification for the runner.

Adding to task list

@zimmski zimmski mentioned this pull request May 16, 2024
45 tasks
@zimmski
Copy link
Member

zimmski commented May 16, 2024

Can we make this a CLI provider too?

Change this so it takes a constructor that has the command line string to shell out to. Should support ollama cli, llm cli ... that saves all the network headache.

func (p *ollamaQueryProvider) Query(ctx context.Context, modelIdentifier string, promptText string) (response string, err error) {

For testing I would just mostly mock, but you could roll the Shakespeare mini llm for integration tests. https://github.com/ggerganov/llama.cpp/blob/master/examples/train-text-from-scratch/README.md

Adding this to our task list as well. Unfortunately did not find a good way of doing this yet. Might be that the more functionality we add, the harder this gets 😿

@zimmski zimmski self-assigned this May 18, 2024
@zimmski zimmski mentioned this pull request Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants