ooo
This commit is contained in:
37
home-modules/ollama.nix
Normal file
37
home-modules/ollama.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
(writers.writePython3Bin "ooo" {
|
||||
libraries = [ pkgs.python3Packages.ollama ];
|
||||
flakeIgnore = [ "E501" "E305" "E701" "E704" "E302" "E114" "F841" "E121" ];
|
||||
} /* python */ ''
|
||||
import sys
|
||||
import ollama
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: ./ooo.py <system_message>")
|
||||
sys.exit(1)
|
||||
|
||||
system_message = sys.argv[1]
|
||||
input_text = sys.stdin.read()
|
||||
try:
|
||||
response = ollama.chat(model='llama3.1:8b', messages=[
|
||||
{
|
||||
'role': 'system',
|
||||
'content': "You are a text transformer. Follow the folling instruction:\n\n" + system_message + "\n\nOnly output the transformed text. Do not add any addidional conversation around the output. Just the result.",
|
||||
},
|
||||
{
|
||||
'role': 'user',
|
||||
'content': input_text,
|
||||
},
|
||||
])
|
||||
|
||||
print(response['message']['content'])
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user