-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds LLM feature to next - Creates endpoints in flask - Adds conditional logic checking for OPEN_API_KEY - Update READEME.md
- Loading branch information
Showing
8 changed files
with
223 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import { NextResponse } from "next/server"; | ||
import { getProductsOnly } from '@/lib/data.js'; | ||
import { | ||
determineBackendUrl, | ||
} from '@/src/utils/backendrouter'; | ||
|
||
|
||
export async function GET(request) { | ||
const backendUrl = determineBackendUrl('flask'); | ||
|
||
const resp = await fetch(backendUrl + `/showSuggestion`, { | ||
method: 'GET', | ||
headers: { 'Content-Type': 'application/json' }, | ||
}) | ||
.then((result) => { | ||
if (!result.ok) { | ||
// Sentry.setContext('err', { | ||
// status: result.status, | ||
// statusText: result.statusText, | ||
// }); | ||
return Promise.reject(); | ||
} else { | ||
return result.json(); | ||
} | ||
}); | ||
|
||
return NextResponse.json({ response: resp.response }, { status: 200 }) | ||
} | ||
|
||
function extractRelevantDataAsString(items) { | ||
return items.map(item => | ||
`Title: ${item.title}, Description: ${item.description}, Price: ${item.price}` | ||
).join('; '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
import { NextResponse } from "next/server"; | ||
import { getProductsOnly } from '@/lib/data.js'; | ||
import { | ||
determineBackendUrl, | ||
} from '@/src/utils/backendrouter'; | ||
|
||
|
||
export async function GET(request) { | ||
console.log("Sending ai suggeestion request...") | ||
const geo = request.nextUrl.searchParams.get("geo"); | ||
const productsFull = await getProductsOnly(); | ||
const products = extractRelevantDataAsString(productsFull); | ||
|
||
const backendUrl = determineBackendUrl('flask'); | ||
|
||
const resp = await fetch(backendUrl + `/suggestion?catalog=${products}&geo=${geo}`, { | ||
method: 'GET', | ||
headers: { 'Content-Type': 'application/json' }, | ||
}) | ||
.then((result) => { | ||
if (!result.ok) { | ||
// Sentry.setContext('err', { | ||
// status: result.status, | ||
// statusText: result.statusText, | ||
// }); | ||
return Promise.reject(); | ||
} else { | ||
return result.json(); | ||
} | ||
}); | ||
|
||
return NextResponse.json({ suggestion: resp.suggestion }, { status: 200 }) | ||
} | ||
|
||
function extractRelevantDataAsString(items) { | ||
return items.map(item => | ||
`Title: ${item.title}, Description: ${item.description}, Price: ${item.price}` | ||
).join('; '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters