Skip to content

Commit

Permalink
modified names of citation keys before updating supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyubibrahimi committed Nov 15, 2023
1 parent a283e2b commit bd963df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/googlecloud/functions/getanswer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@


def update_supabase(responses, citations, card_id):
transformed_citations = []
for citation in citations:
transformed_citations.append({
"source_title": citation.get("Title"),
"source_name": citation.get("Name"),
"source_publish_date": citation.get("Published"),
"source_url": citation.get("URL")
})

try:
supabase.table("cards").update(
{"responses": responses, "citations": citations}
{"responses": responses, "citations": transformed_citations}
).eq("id", card_id).execute()
logging.info("Data successfully updated in Supabase")
except Exception as e:
Expand Down
20 changes: 20 additions & 0 deletions packages/web/components/NewQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ export default function NewQuery() {
}
};

const fetchUpdatedCard = async (cardId: string) => {
const { data, error } = await supabase
.from('cards')
.select('*')
.eq('id', cardId)
.single();

if (error) {
console.error('Error fetching updated card:', error);
} else if (data) {
setCard(data);
}
};


const sendQueryToFunction = async (newCard: ICard) => {
// Start processing question
const answerResp = await fetch(apiEndpoint, {
Expand Down Expand Up @@ -91,6 +106,11 @@ export default function NewQuery() {
card = card as ICard;
setQuery("");
setIsProcessing(false);
if (newCard.id) {
await fetchUpdatedCard(newCard.id);
} else {
console.error('Card ID is undefined');
}
};

useEffect(() => {
Expand Down

0 comments on commit bd963df

Please sign in to comment.