Guest User

llm-python-chat.py

a guest
Dec 31st, 2024
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. #!/bin/python3
  2.  
  3. import re
  4. import sys
  5. from openai import OpenAI
  6.  
  7. system = sys.argv[1]
  8. prompt = sys.argv[2]
  9. temp = sys.argv[3]
  10.  
  11. # Point to the local server
  12. client = OpenAI(base_url="http://127.0.0.1:9090/v1", api_key="none")
  13.  
  14. completion = client.chat.completions.create(
  15.   model="llama3.2",
  16.   messages=[
  17.     {"role": "system", "content": system },
  18.     {"role": "user", "content": prompt }
  19.   ],
  20.   temperature=temp,
  21. )
  22.  
  23. print(completion.choices[0].message.content.strip())
  24.  
Tags: api llm
Advertisement
Add Comment
Please, Sign In to add comment