Skip to content

Commit

Permalink
return template model card as json obj if model card generation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
j2whiting committed Feb 6, 2024
1 parent 63f20a6 commit 3784698
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions core/openai/prompts/model_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"TechnicalSpecifications": {
"model_specs": "Details about the model's complexity, such as the number of places, transitions, parameter count, and arcs."
},
"Glossary": {
"terms": []
},
"ModelCardAuthors": [],
Expand All @@ -30,13 +31,12 @@
"Citation": {
"references": []
},
"Glossary": {
"terms": []
},
"MoreInformation": {
"links": []
}
}
"""

INSTRUCTIONS = """
You are a helpful agent designed to populate a model card containing metadata about a given research paper and its associated model.\n
Use the following research paper as a reference: ---PAPER START---{research_paper}---PAPER END--. Ensure that the output follows the below model card format.\n
Expand Down
5 changes: 3 additions & 2 deletions core/openai/tool_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime
import json
from openai import OpenAI, AsyncOpenAI
from typing import List
from core.entities import Tool
Expand Down Expand Up @@ -59,7 +60,7 @@ def model_card_chain(research_paper: str):
)
model_card = extract_json("{" + output.choices[0].message.content)
if model_card is None:
return MODEL_CARD_TEMPLATE
return json.loads(MODEL_CARD_TEMPLATE)
return model_card


Expand All @@ -84,7 +85,7 @@ async def amodel_card_chain(research_paper: str):
)
model_card = extract_json("{" + response.choices[0].message.content)
if model_card is None:
return MODEL_CARD_TEMPLATE
return json.loads(MODEL_CARD_TEMPLATE)
return model_card


Expand Down

0 comments on commit 3784698

Please sign in to comment.