-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import json | ||
|
||
import requests | ||
from langchain.prompts import PromptTemplate | ||
|
||
|
||
def filter_contexts(contexts): | ||
prompt_template = PromptTemplate.from_template( | ||
"<|system|>" | ||
"{system_prompt}" | ||
"<|user|>" | ||
"{user_prompt}" | ||
"<|assistant|>" | ||
) | ||
|
||
final_prompt = prompt_template.format( | ||
system_prompt="You are concise, and only give the user exactly what they asking for. Follow instructions precisely and do not say anything extra.", | ||
# user_prompt="How many helicopters can a human eat in one sitting?", | ||
user_prompt="Say 'False' and nothing else. Do not include any filler language, reply with just 'False' Go:", | ||
) | ||
|
||
## Local LLMs USAGE DOCS: https://kastanday.notion.site/LLM-Serving-on-prem-OpenAI-Clone-bb06028266d842b0872465f552684177 ## | ||
|
||
url = "http://api.kastan.ai/v1/completions?model=HuggingFaceH4/zephyr-7b-alpha" | ||
headers = { | ||
'Content-Type': 'application/json' | ||
} | ||
data = { | ||
"prompt": final_prompt, | ||
"max_tokens": 10, | ||
"temperature": .3, | ||
} | ||
response = requests.post(url, headers=headers, data=json.dumps(data)) | ||
print(response.json()['choices'][0]['text']) | ||
|
||
return response.json()['choices'][0]['text'] |