Skip to content

Commit

Permalink
Fix Missing Dependency, Wrong Relative paths (#304)
Browse files Browse the repository at this point in the history
* Changes added

* Changes added

* Changes added--02

* Changes added--02

* Changes added

---------

Co-authored-by: Mohd Saif Khan <[email protected]>
  • Loading branch information
parteek2813 and MSaifKhan01 authored Jan 12, 2024
1 parent df7aa7a commit eb20475
Show file tree
Hide file tree
Showing 68 changed files with 2,290 additions and 11 deletions.
2 changes: 1 addition & 1 deletion JS/edgechains/examples/hydeSearch/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion JS/edgechains/examples/hydeSearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"typescript": "^5.3.2"
},
"devDependencies": {
"@arakoodev/edgechains.js": "^0.1.10",
"@hanazuki/node-jsonnet": "^2.1.0",
"@types/jest": "^29.5.8",
"@types/node": "^20.9.4",
Expand All @@ -40,7 +41,6 @@
"jest": "^29.7.0",
"prettier": "^3.1.0",
"react": "^18.2.0",
"@arakoodev/edgechains.js": "0.1.10",
"ts-jest": "^29.1.1",
"tsx": "^3.12.2",
"typeorm": "^0.3.17",
Expand Down
1 change: 1 addition & 0 deletions JS/edgechains/examples/hydeSearch/src/HydeSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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 () => {
Expand Down
4 changes: 2 additions & 2 deletions JS/edgechains/examples/hydeSearch/src/HydeSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ async function hydeSearchAdaEmbedding(arkRequest: ArkRequest, apiKey: string, or
//
const jsonnet = new Jsonnet();

const promptPath = path.join(__dirname, "../src/prompts.jsonnet");
const hydePath = path.join(__dirname, "../src/hyde.jsonnet");
const promptPath = path.join(__dirname, "../jsonnet/prompts.jsonnet");
const hydePath = path.join(__dirname, "../jsonnet/hyde.jsonnet");
// Load Jsonnet to extract args..
const promptLoader = await jsonnet.evaluateFile(promptPath);

Expand Down
2 changes: 1 addition & 1 deletion JS/edgechains/examples/react-chain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"typescript": "^5.3.2"
},
"devDependencies": {
"@arakoodev/edgechains.js": "0.1.10",
"@hanazuki/node-jsonnet": "^2.1.0",
"@types/jest": "^29.5.8",
"@types/node": "^20.9.4",
Expand All @@ -40,7 +41,6 @@
"jest": "^29.7.0",
"prettier": "^3.1.0",
"react": "^18.2.0",
"@arakoodev/edgechains.js": "0.1.10",
"ts-jest": "^29.1.1",
"tsx": "^3.12.2",
"typeorm": "^0.3.17",
Expand Down
7 changes: 6 additions & 1 deletion JS/edgechains/examples/react-chain/src/ReactChain.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const reactChain = require("./ReactChain");
// const reactChain = require("./ReactChain");

import { reactChain } from "./ReactChain";




describe("ReAct Chain", () => {
it("should return a response", async () => {
Expand Down
7 changes: 6 additions & 1 deletion JS/edgechains/examples/react-chain/src/ReactChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as path from "path";
import { Hono } from "hono";
import axios from "axios";

let OPENAI_API_KEY = process.env.OPENAI_API_KEY;


const jsonnet = new Jsonnet();

jsonnet.nativeCallback(
Expand Down Expand Up @@ -58,7 +61,7 @@ export const ReactChainRouter = new Hono();

const gpt3Endpoint = new OpenAiEndpoint(
"https://api.openai.com/v1/chat/completions",
process.env.OPENAI_API_KEY!,
OPENAI_API_KEY,
"",
"gpt-3.5-turbo",
"user",
Expand All @@ -75,6 +78,7 @@ ReactChainRouter.post("/react-chain", async (c) => {
});

export async function reactChain(query) {
console.log("test04:- ",query)
var reactJsonnet = await jsonnet
.extString("gptResponse", "")
.extString("context", "This is contenxt")
Expand All @@ -93,6 +97,7 @@ export async function reactChain(query) {
context = context + query;

jsonnet.extString("context", context).extString("gptResponse", gptResponse);
console.log("test05 :-",gptResponse)

while (!checkIfFinished(gptResponse)) {
reactJsonnet = await jsonnet.evaluateFile(reactChainJsonnetPath);
Expand Down
11 changes: 11 additions & 0 deletions JS/edgechains/examples/react-chain/test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

export default {
preset: 'ts-jest',
testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
};

3 changes: 2 additions & 1 deletion JS/edgechains/examples/react-chain/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"types": ["dotenv/config", "jest", "node"],
"types": [ "jest", "node"],
// "dotenv/config",
"target": "ES2022",
"module": "NodeNext",
"esModuleInterop": true,
Expand Down
12 changes: 12 additions & 0 deletions JS/edgechains/lib/Test03/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "test03",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
4 changes: 4 additions & 0 deletions JS/edgechains/lib/create-edgechains/__common/htmljs.d.ts
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;
52 changes: 52 additions & 0 deletions JS/edgechains/lib/create-edgechains/__common/htmljs.js
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>`;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "dotenv/config";
12 changes: 12 additions & 0 deletions JS/edgechains/lib/create-edgechains/__common/src/index.js
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");
});
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;
Loading

0 comments on commit eb20475

Please sign in to comment.