Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evref-bl/pharo-llmapi
Use LLM API from Pharo
https://github.com/evref-bl/pharo-llmapi
llm pharo
Last synced: 10 days ago
JSON representation
Use LLM API from Pharo
- Host: GitHub
- URL: https://github.com/evref-bl/pharo-llmapi
- Owner: Evref-BL
- Created: 2024-11-14T14:39:03.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-01-23T12:42:58.000Z (12 days ago)
- Last Synced: 2025-01-23T13:27:07.712Z (12 days ago)
- Topics: llm, pharo
- Language: Smalltalk
- Homepage:
- Size: 144 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pharo LLM API
## Installation
```st
Metacello new
githubUser: 'Evref-BL' project: 'Pharo-LLMAPI' commitish: 'main' path: 'src';
baseline: 'LLMAPI';
load
```## Example
### For the chat
```st
api := LLMAPI chat.
api host: 'api.mistral.ai'.
api apiKey: ''.api payload
temperature: 0.5;
model: 'mistral-small-latest';
top_p: 1;
max_tokens: 250;
messages: {
LLMAPIChatObjectMessage role: 'system' content: 'You are a usefull assistant'.
LLMAPIChatObjectMessage role: 'user' content: 'How to write hello world in Pharo?'.
}.result := api performRequest.
```#### Using tools (function call)
You can also create code that will be called by the LLM.
It is named function call or function tool.```st
api := LLMAPI chat.
api host: 'api.mistral.ai'.api payload
temperature: 0.5;
model: 'mistral-small-latest';
top_p: 1;
max_tokens: 250;
tools: { (LLMAPIChatObjectToolCountClasses new) };
messages: {
(LLMAPIChatObjectMessage
role: 'system'
content: 'You are a usefull assistant').
(LLMAPIChatObjectMessage
role: 'user'
content: 'What is the number of classes in my computer ? ') }.result := api performRequest.
```
### For the FIM
```st
api := LLMAPI fim.
api host: 'api.mistral.ai'.
api apiKey: ''.api payload
temperature: 0.2;
model: 'codestral-2405';
top_p: 1;
max_tokens: 250;
prompt: 'def';
suffix: 'return a + b'.
result := api performRequest.
```## UI
This project also includes a simple UI. Feel free to use it, improve it, and contribute.
Open it with:
```st
LLMAPISpec open
```![alt text](doc/image.png)