Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,20 +60,9 @@ if torch.cuda.is_available():
|
|
| 60 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 61 |
tokenizer.pad_token = tokenizer.eos_token
|
| 62 |
|
| 63 |
-
# # MongoDB Connection
|
| 64 |
-
# PASSWORD = os.environ.get("MONGO_PASS")
|
| 65 |
-
# connect(host=f"mongodb+srv://ranamhammoud11:{PASSWORD}@stories.zf5v52a.mongodb.net/")
|
| 66 |
|
| 67 |
-
# # MongoDB Document
|
| 68 |
-
# class Story(Document):
|
| 69 |
-
# message = StringField()
|
| 70 |
-
# content = StringField()
|
| 71 |
-
# story_id = SequenceField(primary_key=True)
|
| 72 |
-
|
| 73 |
-
# Utility function for prompts
|
| 74 |
def make_prompt(entry):
|
| 75 |
return f"### Human: When asked to explain use a story.Don't repeat the assesments, limit to 500 words.However keep context in mind if edits to the content is required. {entry} ### Assistant:"
|
| 76 |
-
# f"TELL A STORY, RELATE TO COMPUTER SCIENCE, INCLUDE ASSESMENTS. MAKE IT REALISTIC AND AROUND 800 WORDS, END THE STORY WITH "THE END.": {entry}"
|
| 77 |
|
| 78 |
def process_text(text):
|
| 79 |
|
|
@@ -142,15 +131,12 @@ def generate(
|
|
| 142 |
yield output
|
| 143 |
|
| 144 |
final_story = "".join(outputs)
|
| 145 |
-
generate_image(final_story)
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
# yield f"Failed to save story: {str(e)}"
|
| 151 |
-
|
| 152 |
|
| 153 |
-
chatbot=gr.Chatbot([(None, ("https://img.freepik.com/free-photo/painting-mountain-lake-with-mountain-background_188544-9126.jpg",))])
|
| 154 |
chat_interface = gr.ChatInterface(
|
| 155 |
fn=generate,
|
| 156 |
fill_height=True,
|
|
@@ -160,7 +146,7 @@ chat_interface = gr.ChatInterface(
|
|
| 160 |
["Could you please provide an explanation about the concept of recursion?"],
|
| 161 |
["Could you explain what a URL is?"]
|
| 162 |
],
|
| 163 |
-
theme='shivi/calm_seafoam',autofocus=True
|
| 164 |
)
|
| 165 |
|
| 166 |
# Gradio Web Interface
|
|
|
|
| 60 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 61 |
tokenizer.pad_token = tokenizer.eos_token
|
| 62 |
|
|
|
|
|
|
|
|
|
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
def make_prompt(entry):
|
| 65 |
return f"### Human: When asked to explain use a story.Don't repeat the assesments, limit to 500 words.However keep context in mind if edits to the content is required. {entry} ### Assistant:"
|
|
|
|
| 66 |
|
| 67 |
def process_text(text):
|
| 68 |
|
|
|
|
| 131 |
yield output
|
| 132 |
|
| 133 |
final_story = "".join(outputs)
|
| 134 |
+
image_url = generate_image(final_story)
|
| 135 |
+
yield image_url
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
|
|
|
|
|
|
|
| 139 |
|
|
|
|
| 140 |
chat_interface = gr.ChatInterface(
|
| 141 |
fn=generate,
|
| 142 |
fill_height=True,
|
|
|
|
| 146 |
["Could you please provide an explanation about the concept of recursion?"],
|
| 147 |
["Could you explain what a URL is?"]
|
| 148 |
],
|
| 149 |
+
theme='shivi/calm_seafoam',autofocus=True
|
| 150 |
)
|
| 151 |
|
| 152 |
# Gradio Web Interface
|