Skip to content

Commit

Permalink
Use opportunity link in result (#9)
Browse files Browse the repository at this point in the history
* add opportunityUrl to embedding metadata

* get opportunityUrl from embedding result

* 🎨 use backupUrl in case opportunityUrl is null
  • Loading branch information
ff137 authored Nov 15, 2023
1 parent 79dc4b0 commit 98ea723
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/xyz/didx/ai/AiHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,17 @@ object AiHandler {

scribe.info(logResult)

val topMatch: TextSegment = embeddingMatch.embedded()
val id: String = topMatch.metadata("id")
val title: String = topMatch.metadata("title")
val organisation: String = topMatch.metadata("organisationName")
val url: String = s"https://app.yoma.world/opportunities/$id"
val topMatch: TextSegment = embeddingMatch.embedded()
val id: String = topMatch.metadata("id")
val title: String = topMatch.metadata("title")
val organisation: String = topMatch.metadata("organisationName")
val opportunityUrl: String = topMatch.metadata("opportunityURL")

val backupUrl: String = s"https://app.yoma.world/opportunities/$id"

val url = opportunityUrl match
case null | "null" | "" => backupUrl // handle potential edge cases
case _ => opportunityUrl

val response: String =
s"You might be interested in: $title, by $organisation. Here's a link to the opportunity page: $url"
Expand Down
1 change: 1 addition & 0 deletions src/xyz/didx/ai/embedding/EmbeddingHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ object EmbeddingHandler {
.add("id", opportunity.id)
.add("title", opportunity.title)
.add("organisationName", opportunity.organisationName)
.add("opportunityURL", opportunity.opportunityURL)

val opportunityEmbeddingInput: String =
removeSpecialCharacters(s"""${opportunity.title} ${opportunity.description}""")
Expand Down

0 comments on commit 98ea723

Please sign in to comment.