Nikola299 commited on
Commit
1b140ef
1 Parent(s): 7f17cd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -32
app.py CHANGED
@@ -5,35 +5,34 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
5
  print("runningg")
6
 
7
 
8
- #torch.random.manual_seed(0)
9
- #model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct",trust_remote_code=True)
10
- #tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
11
-
12
- #text = st.text_area("Enter text....")
13
- #messages = [
14
- # {"role": "system", "content": "You are a helpful AI assistant."},
15
- # {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
16
- # {"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
17
- # {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
18
- #]
19
-
20
-
21
- #pipe = pipeline(
22
- # "text-generation",
23
- # model=model,
24
- # tokenizer=tokenizer,
25
- #)
26
-
27
- #generation_args = {
28
- # "max_new_tokens": 500,
29
- # "return_full_text": False,
30
- # "temperature": 0.0,
31
- # "do_sample": False,
32
- #}
33
-
34
- #output = pipe(messages, **generation_args)
35
-
36
- #if text:
37
- # out = pipe(text)
38
- # st.write(out)
39
- st.write("aaa")
 
5
  print("runningg")
6
 
7
 
8
+ torch.random.manual_seed(0)
9
+ model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct",trust_remote_code=True)
10
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
11
+
12
+ text = st.text_area("Enter text....")
13
+ messages = [
14
+ {"role": "system", "content": "You are a helpful AI assistant."},
15
+ {"role": "user", "content": "Can you provide ways to eat combinations of bananas and dragonfruits?"},
16
+ {"role": "assistant", "content": "Sure! Here are some ways to eat bananas and dragonfruits together: 1. Banana and dragonfruit smoothie: Blend bananas and dragonfruits together with some milk and honey. 2. Banana and dragonfruit salad: Mix sliced bananas and dragonfruits together with some lemon juice and honey."},
17
+ {"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
18
+ ]
19
+
20
+
21
+ pipe = pipeline(
22
+ "text-generation",
23
+ model=model,
24
+ tokenizer=tokenizer,
25
+ )
26
+
27
+ generation_args = {
28
+ "max_new_tokens": 500,
29
+ "return_full_text": False,
30
+ "temperature": 0.0,
31
+ "do_sample": False,
32
+ }
33
+
34
+ output = pipe(messages, **generation_args)
35
+
36
+ if text:
37
+ out = pipe(text)
38
+ st.write(out)