You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Matt Williams 5a85070c22
Update readmes, requirements, packagejsons, etc for all examples (#1452)
2 years ago
..
README.md Update readmes, requirements, packagejsons, etc for all examples (#1452) 2 years ago
client.py Update readmes, requirements, packagejsons, etc for all examples (#1452) 2 years ago
requirements.txt Update readmes, requirements, packagejsons, etc for all examples (#1452) 2 years ago

README.md

Simple Generate Example

This is a simple example using the Generate endpoint.

Running the Example

  1. Ensure you have the stablelm-zephyr model installed:

    ollama pull stablelm-zephyr
    
  2. Install the Python Requirements.

    pip install -r requirements.txt
    
  3. Run the example:

    python client.py
    

Review the Code

The main function simply asks for input, then passes that to the generate function. The output from generate is then passed back to generate on the next run.

The generate function uses requests.post to call /api/generate, passing the model, prompt, and context. The generate endpoint returns a stream of JSON blobs that are then iterated through, looking for the response values. That is then printed out. The final JSON object includes the full context of the conversation so far, and that is the return value from the function.