ashioyajotham commited on
Commit
f3676ad
1 Parent(s): de81baf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -7,18 +7,19 @@ tokenizer = AutoTokenizer.from_pretrained(fine_tuned_model, trust_remote_code=Tr
7
  # Set the padding token to be the same as the end-of-sequence token
8
  tokenizer.pad_token = tokenizer.eos_token
9
 
10
- def generate_code(input_text):
11
- inputs = tokenizer.encode(input_text, return_tensors='pt')
12
- # Use your fine-tuned model to generate code here
13
- generated_code = fine_tuned_model.generate(input_text, max_length=100, temperature = .7, do_sample=True, pad_token_id=tokenizer.eos_token_id)
14
- completion = tokenizer.decode(generated_code[0])
15
 
16
- return completion
17
 
 
 
 
 
 
18
  import gradio as gr
19
 
20
  iface = gr.Interface(
21
- fn=generate_code,
22
  inputs="text",
23
  outputs="text",
24
  title="Code Generation App",
 
7
  # Set the padding token to be the same as the end-of-sequence token
8
  tokenizer.pad_token = tokenizer.eos_token
9
 
10
+ prompt = "Generate a Python script to add prime numbers between one and ten"
 
 
 
 
11
 
12
+ inputs = tokenizer.encode(prompt, return_tensors='pt')
13
 
14
+ outputs = model.generate(inputs, max_length=100, temperature = .7, do_sample=True, pad_token_id=tokenizer.eos_token_id)
15
+
16
+ completion = tokenizer.decode(outputs[0])
17
+
18
+ #print(completion)
19
  import gradio as gr
20
 
21
  iface = gr.Interface(
22
+ fn=completion,
23
  inputs="text",
24
  outputs="text",
25
  title="Code Generation App",