Skip to content

Commit

Permalink
Added LLM route
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes221 committed Mar 21, 2024
1 parent 3f0ff62 commit f00e882
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 1 deletion.
Empty file added backend/llm/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions backend/llm/llm_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import json
import predictionguard as pg

# Set your Prediction Guard token as an environmental variable.

os.environ["PREDICTIONGUARD_TOKEN"] = "q1VuOjnffJ3NO2oFN8Q9m8vghYc84ld13jaqdF7E"

def get_response(user_message):
# Define the system and user messages.
messages = [
{
"role": "system",
"content": "You are a helpful assistant. Your model is hosted by Prediction Guard, a leading AI company."
},
{
"role": "user",
"content": user_message
}
]

# Get the response using Prediction Guard.
result = pg.Chat.create(model="Neural-Chat-7B", messages=messages)

# Extract and return the response.
return result['messages'][-1]['content']
179 changes: 178 additions & 1 deletion backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f00e882

Please sign in to comment.