Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evref-bl/pharo-ollamaapi
https://github.com/evref-bl/pharo-ollamaapi
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/evref-bl/pharo-ollamaapi
- Owner: Evref-BL
- License: mit
- Created: 2023-11-08T13:15:53.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-18T18:12:04.000Z (5 months ago)
- Last Synced: 2024-07-19T00:44:17.078Z (5 months ago)
- Language: Smalltalk
- Size: 48.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pharo-OllamaAPI
[![Pharo 12](https://img.shields.io/badge/Pharo-12-%23aac9ff.svg)](https://github.com/pharo-project/pharo)
[![Moose version](https://img.shields.io/badge/Moose-12-%23aac9ff.svg)](https://github.com/moosetechnology/Moose)This is a simple API to call the [Ollama API](https://github.com/jmorganca/ollama/blob/main/docs/api.md)
> You must first install [Ollama](https://ollama.ai/) on your computer
## Example
### Generate code with CodeLlama
```st
ollama := OllamaAPI new.
ollama model: OCodeLlamaModel new.
ollama model tag: '7b-code'.
ollama temperature: 0.1.
ollama num_predict: 30.
ollama top_p: 0.5.ollama query: '
'
```### Generate a comment code with CodeLlama
```st
ollama := OllamaAPI new.
ollama model: OCodeLlamaModel new.
ollama model tag: '7b'.
ollama temperature: 0.5.
ollama num_predict: 75.
ollama top_p: 0.5.ollama query: 'Writte a comment that explain this function
'
```### Use the stream API
```st
[ollama := OllamaAPI new.
ollama model: OCodeLlamaModel new.
ollama model tag: '7b'.
ollama temperature: 0.5.
ollama num_predict: 100.
ollama top_p: 0.5.
ollama stream: true.answer := ollama query: 'Hello world'.
reader := NeoJSONReader on: (ZnCharacterReadStream on: answer).
[ reader atEnd ] whileFalse: [
| val |
val := reader next.
Transcript crShow: (val at: #response).
(val at: #done) ifTrue: [ answer close ] ]] forkAt: Processor lowIOPriority
```## Installation
```st
Metacello new
githubUser: 'Evref-BL' project: 'Pharo-OllamaAPI' commitish: 'main' path: 'src';
baseline: 'PharoOllama';
load
```### As a dependency
```st
spec
baseline: 'PharoOllama'
with: [
spec repository: 'github://Evref-BL/Pharo-OllamaAPI:main/src' ]
```