Skip to content

Commit

Permalink
complete docSearch and image generation action
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamjagga committed Jun 28, 2024
1 parent 276049d commit 5149a1c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions fastapi-rest-apis/actions/scripts/docSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
def find_occurrences(text, keyword):
occurrences = text.lower().count(keyword.lower())
return occurrences
def get_output():
def get_output(input_json):
try:
input_json = json.loads(sys.argv[1])
text = input_json["text"]
keyword = input_json["keyword"]
num_occurrences = find_occurrences(text, keyword)
Expand Down
4 changes: 2 additions & 2 deletions fastapi-rest-apis/actions/scripts/generateImageFromText.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def get_output():
def get_output(input_json):
try:
import requests
import json
from craiyon import Craiyon
generator = Craiyon() # Instantiates the api wrapper
result = generator.generate("Photorealistic image of shrek eating earth", negative_prompt="spoon", model_type="art")
result = generator.generate(input_json["prompt"], negative_prompt="spoon", model_type="art")
print(json.dumps({"output": {"type": "text", "content": f"{result.description}"}}))
except Exception as e:
print(json.dumps({"output": {"type": "error", "content": e}}))
Expand Down
Binary file modified fastapi-rest-apis/db/__pycache__/index.cpython-310.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions fastapi-rest-apis/db/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

DB_URL = os.environ['DB_URL']



def createDBSession():
engine = create_engine(DB_URL)
Session = sessionmaker(bind=engine)
Expand Down
Binary file modified fastapi-rest-apis/requirements.txt
Binary file not shown.

0 comments on commit 5149a1c

Please sign in to comment.