-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e839341
commit c90fa9f
Showing
48 changed files
with
8,574 additions
and
6,814 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
import { ArkRequest } from "@arakoodev/edgechains.js"; | ||
import dotenv from "dotenv"; | ||
|
||
import { hydeSearchAdaEmbedding } from "./HydeSearch"; | ||
|
||
dotenv.config({ path: ".env" }); | ||
describe("Hyde Search", () => { | ||
it("should return a response", async () => { | ||
const arkRequest: ArkRequest = { | ||
topK: 5, | ||
metadataTable: "title_metadata", | ||
query: "tell me the top 5 programming languages currently", | ||
textWeight: { | ||
baseWeight: "1.0", | ||
fineTuneWeight: "0.35", | ||
}, | ||
similarityWeight: { | ||
baseWeight: "1.5", | ||
fineTuneWeight: "0.40", | ||
}, | ||
dateWeight: { | ||
baseWeight: "1.25", | ||
fineTuneWeight: "0.75", | ||
}, | ||
orderRRF: "default", | ||
}; | ||
expect( | ||
( | ||
await hydeSearchAdaEmbedding( | ||
arkRequest, | ||
process.env.OPENAI_API_KEY!, | ||
process.env.OPENAI_ORG_ID! | ||
) | ||
).finalAnswer | ||
).toContain("Java"); | ||
}, 30000); | ||
it("should return a response", async () => { | ||
const arkRequest: ArkRequest = { | ||
topK: 5, | ||
metadataTable: "title_metadata", | ||
query: "tell me the top 5 programming languages currently", | ||
textWeight: { | ||
baseWeight: "1.0", | ||
fineTuneWeight: "0.35", | ||
}, | ||
similarityWeight: { | ||
baseWeight: "1.5", | ||
fineTuneWeight: "0.40", | ||
}, | ||
dateWeight: { | ||
baseWeight: "1.25", | ||
fineTuneWeight: "0.75", | ||
}, | ||
orderRRF: "default", | ||
}; | ||
expect( | ||
( | ||
await hydeSearchAdaEmbedding( | ||
arkRequest, | ||
process.env.OPENAI_API_KEY!, | ||
process.env.OPENAI_ORG_ID! | ||
) | ||
).finalAnswer | ||
).toContain("Java"); | ||
}, 30000); | ||
}); |
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": ["dotenv/config", "jest", "node"], | ||
"target": "ES2022", | ||
"module": "NodeNext", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "hono/jsx", | ||
"noImplicitAny": false, | ||
"moduleResolution": "NodeNext", | ||
"declaration": true | ||
}, | ||
"include": ["src/**/*.ts", "dist/**/*.d.ts"] | ||
"compilerOptions": { | ||
"types": ["dotenv/config", "jest", "node"], | ||
"target": "ES2022", | ||
"module": "NodeNext", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "hono/jsx", | ||
"noImplicitAny": false, | ||
"moduleResolution": "NodeNext", | ||
"declaration": true | ||
}, | ||
"include": ["src/**/*.ts", "dist/**/*.d.ts"] | ||
} |
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,4 @@ | ||
export declare const view: (viewToRender: any) => (c: any) => Promise<any>; | ||
export declare const rootLayout: (layoutToApply: any) => (c: any, next: any) => Promise<void>; | ||
export declare const layout: (layoutToApply: any) => (c: any, next: any) => Promise<void>; | ||
export declare const Link: any; |
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,52 @@ | ||
import { html } from "hono/html"; | ||
// These functions form the basis of the html.js framework and will be moved to a separate lib | ||
export const view = (viewToRender) => { | ||
return async (c) => { | ||
const newBody = await viewToRender({ context: c }); | ||
return c.html(newBody); | ||
}; | ||
}; | ||
export const rootLayout = (layoutToApply) => { | ||
return async (c, next) => { | ||
await next(); | ||
if (c.req.header("HX-Request") !== "true") { | ||
// Req is a normal request, so we render the whole page which means adding the root layout | ||
const curBody = await c.res.text(); | ||
c.res = undefined; // To overwrite res, set it to undefined before setting new value https://github.com/honojs/hono/pull/970 released in https://github.com/honojs/hono/releases/tag/v3.1.0 | ||
const newBody = await layoutToApply({ context: c, children: html(curBody) }); | ||
c.res = c.html(newBody); | ||
} | ||
// Else do nothing and let the original response be sent | ||
}; | ||
}; | ||
export const layout = (layoutToApply) => { | ||
return async (c, next) => { | ||
await next(); | ||
if ((c.req.header("HX-Request") === "true" && | ||
(c.req.header("HX-Boosted") === "true" || !c.req.header("HX-Target"))) || | ||
c.req.header("HX-Request") !== "true") { | ||
// Req is regular req or boosted link, so we apply layouts | ||
const curBody = await c.res.text(); | ||
c.res = undefined; // To overwrite res, set it to undefined before setting new value https://github.com/honojs/hono/pull/970 released in https://github.com/honojs/hono/releases/tag/v3.1.0 | ||
const newBody = await layoutToApply({ context: c, children: html(curBody) }); | ||
c.res = c.html(newBody); | ||
} | ||
// Else do nothing and let the original response be sent, which will be a partial update applied to the page with hx-target | ||
}; | ||
}; | ||
export const Link = ({ to, "hx-target": hxTarget, class: className, children }) => { | ||
if (hxTarget) { | ||
return html `<a | ||
href="${to}" | ||
class="${className}" | ||
hx-get="${to}" | ||
hx-target="${hxTarget}" | ||
hx-push-url="true" | ||
hx-swap="morph" | ||
>${children}</a | ||
>`; | ||
} | ||
else { | ||
return html `<a href="${to}" class="${className}" hx-boost="true">${children}</a>`; | ||
} | ||
}; |
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 @@ | ||
import "dotenv/config"; |
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,12 @@ | ||
import "dotenv/config"; | ||
import { serve } from "@hono/node-server"; | ||
import { Hono } from "hono"; | ||
import { HydeSearchRouter } from "./routes/hydeSearch.route.js"; | ||
import { view } from "../htmljs.js"; | ||
import ExampleLayout from "./layouts/ExampleLayout.js"; | ||
const app = new Hono(); | ||
app.route("/", HydeSearchRouter); | ||
app.get("/", view(ExampleLayout)); | ||
serve(app, () => { | ||
console.log("server running on port 3000"); | ||
}); |
3 changes: 3 additions & 0 deletions
3
JS/edgechains/lib/create-edgechains/__common/src/layouts/ExampleLayout.d.ts
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,3 @@ | ||
import { FC } from "hono/jsx"; | ||
declare const ExampleLayout: FC; | ||
export default ExampleLayout; |
Oops, something went wrong.