ChinarQ-AI Uzaiir commited on
Commit
0c31a3b
·
verified ·
1 Parent(s): 563fa9b

Create models//storyGeneration.py (#2)

Browse files

- Create models//storyGeneration.py (c0c042bdb0f56aec179f3b85a0c87b5061e8b2a9)


Co-authored-by: Khan <[email protected]>

Files changed (1) hide show
  1. src/models/storyGeneration.py +16 -0
src/models/storyGeneration.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_huggingface import HuggingFaceEndpoint
2
+ import os
3
+
4
+ hf_token = os.environ.get("HUGGINGFACE_API_TOKEN")
5
+
6
+ story_generator = HuggingFaceEndpoint(
7
+ repo_id="HuggingFaceH4/zephyr-7b-beta",
8
+ huggingfacehub_api_token=hf_token,
9
+ temperature=0.7,
10
+ max_new_tokens=200
11
+ )
12
+
13
+ def generateStory(prompt):
14
+ if not prompt:
15
+ return "Invalid caption input."
16
+ return story_generator.invoke(prompt)