-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (23 loc) · 750 Bytes
/
Copy pathmain.py
File metadata and controls
31 lines (23 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import openai
openai.api_base = "http://localhost:8000/v1"
openai.api_key = "sk-foo"
def completion(prompt):
# The standard OpenAI Completion API call options are available.
return openai.Completion.create(
model="",
prompt=prompt,
max_tokens=500,
temperature=0.7,
stop=[],
)
def main():
# This is the instruct format for Mistral. Details here:
# https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1
prompt = """<s>[INST] Hello, who are you? [/INST]
I'm Assistant, a friendly AI. How can I help you?</s>
[INST] Can you tell me the capital of Finland? [/INST]
"""
response = completion(prompt)
print(response.choices[0].text)
if __name__ == "__main__":
main()