Spaces:
Runtime error
Runtime error
Commit
•
2d9c6bb
1
Parent(s):
5406aaf
Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import InferenceClient
|
2 |
+
|
3 |
+
endpoint_url = "https://your-endpoint-url-here"
|
4 |
+
|
5 |
+
prompt = "Tell me about AI"
|
6 |
+
prompt_template=f'''You are a helpful assistant for fiction writing. Always cut the bullshit and provide concise outlines with useful details. Do not turn your stories into fairy tales, be realistic.
|
7 |
+
### USER: {prompt}
|
8 |
+
### ASSISTANT:
|
9 |
+
'''
|
10 |
+
|
11 |
+
client = InferenceClient(endpoint_url)
|
12 |
+
response = client.text_generation(prompt,
|
13 |
+
max_new_tokens=128,
|
14 |
+
do_sample=True,
|
15 |
+
temperature=0.7,
|
16 |
+
top_p=0.95,
|
17 |
+
top_k=40,
|
18 |
+
repetition_penalty=1.1)
|
19 |
+
|
20 |
+
print(f"Model output: {response}")
|