-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added example with validator in ollama lib
- Loading branch information
Casper Bollen
authored and
Casper Bollen
committed
Mar 8, 2024
1 parent
0532644
commit fbcf902
Showing
3 changed files
with
203 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "fsharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "fsharp" | ||
}, | ||
"vscode": { | ||
"languageId": "polyglot-notebook" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"#load \"load.fsx\"\n", | ||
"\n", | ||
"open Newtonsoft.Json\n", | ||
"open Informedica.Utils.Lib\n", | ||
"open Informedica.Utils.Lib.BCL\n", | ||
"open Informedica.Ollama.Lib\n", | ||
"open Ollama.Operators" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 20, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "fsharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "fsharp" | ||
}, | ||
"vscode": { | ||
"languageId": "polyglot-notebook" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"let validator =\n", | ||
" fun s -> \n", | ||
" match s |> String.contains \"3\" with\n", | ||
" | true -> \"1 + 1 could be 3\" |> Ok\n", | ||
" | false -> \"the answer should include the possibility of a '1 + 1 could be 3'\" |> Error" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 21, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "fsharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "fsharp" | ||
}, | ||
"vscode": { | ||
"languageId": "polyglot-notebook" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Starting conversation with openchat:7b\n", | ||
"\n", | ||
"Options:\n", | ||
"{\"num_keep\":null,\"seed\":101,\"num_predict\":null,\"top_k\":null,\"top_p\":null,\"tfs_z\":null,\"typical_p\":null,\"repeat_last_n\":64,\"temperature\":0.0,\"repeat_penalty\":null,\"presence_penalty\":null,\"frequency_penalty\":null,\"mirostat\":0,\"mirostat_tau\":null,\"mirostat_eta\":null,\"penalize_newline\":null,\"stop\":[],\"numa\":null,\"num_ctx\":2048,\"num_batch\":null,\"num_gqa\":null,\"num_gpu\":null,\"main_gpu\":null,\"low_vram\":null,\"f16_kv\":null,\"vocab_only\":null,\"use_mmap\":null,\"use_mlock\":null,\"rope_frequency_base\":null,\"rope_frequency_scale\":null,\"num_thread\":null}\n", | ||
"\n", | ||
"Got an answer\n", | ||
"\n", | ||
"## Question:\n", | ||
"You are a helpful asistent on general topics\n", | ||
"\n", | ||
"## Answer:\n", | ||
"It seems like you didn't ask any specific question. If you have any topic or question, feel free to ask and I will be happy to help!\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"## Question:\n", | ||
"How does the saying go like the whole is more than the individual parts?\n", | ||
"\n", | ||
"## Answer:\n", | ||
"The saying you're referring to is \"The whole is greater than the sum of its parts.\" This phrase means that the overall value, quality, or function of a system, group, or entity is greater than the combined values, qualities, or functions of its individual components. It emphasizes the importance of understanding and appreciating the interconnectedness and synergy within a whole, rather than just focusing on the individual parts.\n", | ||
"\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"let conversation =\n", | ||
" \"You are a helpful asistent on general topics\"\n", | ||
" |> init Ollama.Models.``openchat:7b``\n", | ||
" >>? \"\"\"\n", | ||
" How does the saying go like the whole is more than the individual parts?\n", | ||
" \"\"\"\n", | ||
" |> fun conv -> \n", | ||
" conv |> Ollama.Conversation.print\n", | ||
" conv" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 22, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "fsharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "fsharp" | ||
}, | ||
"vscode": { | ||
"languageId": "polyglot-notebook" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"\n", | ||
"## Question:\n", | ||
"You are a helpful asistent on general topics\n", | ||
"\n", | ||
"## Answer:\n", | ||
"It seems like you didn't ask any specific question. If you have any topic or question, feel free to ask and I will be happy to help!\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"## Question:\n", | ||
"How does the saying go like the whole is more than the individual parts?\n", | ||
"\n", | ||
"## Answer:\n", | ||
"The saying you're referring to is \"The whole is greater than the sum of its parts.\" This phrase means that the overall value, quality, or function of a system, group, or entity is greater than the combined values, qualities, or functions of its individual components. It emphasizes the importance of understanding and appreciating the interconnectedness and synergy within a whole, rather than just focusing on the individual parts.\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"## Question:\n", | ||
"It seems the answer was not correct because: the answer should include the possibility of a '1 + 1 could be 3'\n", | ||
"Can you try again answering?\n", | ||
"\n", | ||
"That would mean 1 + 1 could be ?\n", | ||
"\n", | ||
"## Answer:\n", | ||
"The saying goes, \"The whole is greater than the sum of its parts.\" This means that when you combine individual elements or components together, they create something greater or more significant than what each part contributes individually. In some cases, like with synergy, the whole can be even greater than the simple addition of the parts (e.g., 1 + 1 could be 3).\n", | ||
"\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"conversation\n", | ||
">>! (\"\"\"\n", | ||
"That would mean 1 + 1 could be ?\n", | ||
"\"\"\" |> Ollama.Message.userWithValidator validator)\n", | ||
"|> Ollama.Conversation.print" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# r "nuget: Newtonsoft.Json" | ||
|
||
#r "../bin/Debug/net8.0/Informedica.Utils.Lib.dll" | ||
#r "../bin/Debug/net8.0/Informedica.Ollama.Lib.dll" | ||
|
||
#load "../Ollama.fs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters