Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use opportunity link in result #9

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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