TRaw commited on
Commit
0baf828
·
1 Parent(s): ae9c964

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import litellm
4
+ from litellm import completion
5
+
6
+ # set env variable
7
+ os.environ["TOGETHERAI_API_KEY"] = "f722a9f6e3afd6b9999e6aee02aeac9e751ea3a67b124c3667ab50c85c7fa99e"
8
+
9
+ litellm.register_prompt_template(
10
+ model="teknium/OpenHermes-2p5-Mistral-7B",
11
+ roles={"system":"<|im_start|>system", "assistant":"<|im_start|>assistant", "user":"<|im_start|>user"}, # tell LiteLLM how you want to map the openai messages to this model
12
+ pre_message_sep= "\n",
13
+ post_message_sep= "\n"
14
+ )
15
+
16
+ def generate_response(user_input):
17
+ messages=[{"role":"user", "content": user_input}]
18
+ response = completion(model="together_ai/teknium/OpenHermes-2p5-Mistral-7B", messages=messages)
19
+ return response
20
+
21
+ def main():
22
+ st.title("Poem Generator")
23
+
24
+ user_input = st.text_input("Enter a topic for your poem:")
25
+
26
+ if st.button("Generate Poem"):
27
+ response = generate_response(user_input)
28
+ st.write("Here is your poem:")
29
+ st.write(response)
30
+
31
+ if __name__ == "__main__":
32
+ main()