prompt
This commit is contained in:
@@ -78,6 +78,7 @@ Issues = "https://git.silveirarosa.com/renatoxsr/monorepo/issues"
|
||||
composectl = "renatoxsr.scripts.composectl:main"
|
||||
bulk-jsonl = "renatoxsr.scripts.bulk_jsonl:main"
|
||||
avaliar-dataset = "renatoxsr.scripts.avaliar_dataset:main"
|
||||
prompt = "renatoxsr.scripts.prompt:main"
|
||||
|
||||
# SETUPTOOLS
|
||||
[tool.setuptools.packages.find]
|
||||
|
||||
@@ -18,3 +18,4 @@ import renatoxsr.utils
|
||||
import renatoxsr.scripts.composectl
|
||||
import renatoxsr.scripts.bulk_jsonl
|
||||
import renatoxsr.scripts.avaliar_dataset
|
||||
import renatoxsr.scripts.prompt
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
#python << '#EOF'
|
||||
# vim: ft=python ts=4 sw=4 et :
|
||||
import requests
|
||||
import os, sys, json, pathlib, argparse
|
||||
|
||||
def parse_args():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument("--model",
|
||||
default="qwen3.5:4b",
|
||||
choices=[
|
||||
"gemma4:e4b",
|
||||
"llama3.2:3b",
|
||||
"llama3.1:8b",
|
||||
"qwen3.5:4b",
|
||||
])
|
||||
|
||||
g = p.add_mutually_exclusive_group()
|
||||
g.add_argument("--pull")
|
||||
g.add_argument("--chat", action="store_true")
|
||||
g.add_argument("--generate", action="store_true")
|
||||
g.add_argument("--endpoint",
|
||||
default="/api/chat",
|
||||
choices=[
|
||||
"/api/chat",
|
||||
"/v1/chat/completions",])
|
||||
g.add_argument("--api",
|
||||
default="ollama",
|
||||
choices=["ollama","openai",])
|
||||
|
||||
url = p.add_mutually_exclusive_group()
|
||||
url.add_argument("--url", default=os.getenv("PROMPT_URL", "http://localhost:11434"))
|
||||
url.add_argument("--host")
|
||||
url.add_argument("--host-port")
|
||||
url.add_argument("--port")
|
||||
return p.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
conf = parse_args()
|
||||
model_slug = conf.model
|
||||
|
||||
try:
|
||||
#while True:
|
||||
#prompt = input(model_slug + "> ")
|
||||
prompt = "What is the meaning of life?"
|
||||
res = requests.post(
|
||||
url="http://192.168.14.20:11434/api/chat",
|
||||
#headers={
|
||||
#"Authorization": f"Bearer {OPENROUTER_API_KEY}",
|
||||
#"HTTP-Referer": "<YOUR_SITE_URL>", # Optional. Site URL for rankings on openrouter.ai.
|
||||
#"X-OpenRouter-Title": "<YOUR_SITE_NAME>", # Optional. Site title for rankings on openrouter.ai.
|
||||
#},
|
||||
data=json.dumps({
|
||||
"model": model_slug,
|
||||
"messages": [{"role": "user","content": prompt}],
|
||||
"reasoning": {"enabled": True},
|
||||
"stream": False,
|
||||
"options": {
|
||||
"num_ctx": 128000,
|
||||
"top_k": 40,
|
||||
"top_p": 0.2,
|
||||
"temperature": 0.1,
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
data = res.json()
|
||||
print(f"{data['message']['role']}: {data['message']['content']}")
|
||||
#response = response['choices'][0]['message']
|
||||
except KeyboardInterrupt as e:
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
#EOF
|
||||
Reference in New Issue
Block a user