From f225f4c91a76fe1fc5cc2574d6c0ca324b261479 Mon Sep 17 00:00:00 2001 From: Priyan Vaithilingam Date: Wed, 3 May 2023 12:04:16 -0400 Subject: [PATCH] BASE_URL --- chain-forge/src/EvaluatorNode.js | 3 ++- chain-forge/src/InspectorNode.js | 3 ++- chain-forge/src/PromptNode.js | 3 ++- chain-forge/src/ScriptNode.js | 8 -------- chain-forge/src/VisNode.js | 5 +++-- chain-forge/src/store.js | 6 ++++-- python-backend/app.py | 2 -- python-backend/test.html | 4 ++-- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/chain-forge/src/EvaluatorNode.js b/chain-forge/src/EvaluatorNode.js index bed0344..34edb91 100644 --- a/chain-forge/src/EvaluatorNode.js +++ b/chain-forge/src/EvaluatorNode.js @@ -4,6 +4,7 @@ import useStore from './store'; import StatusIndicator from './StatusIndicatorComponent' import NodeLabel from './NodeLabelComponent' import AlertModal from './AlertModal' +import {BASE_URL} from './store'; // Ace code editor import AceEditor from "react-ace"; @@ -80,7 +81,7 @@ const EvaluatorNode = ({ data, id }) => { console.log(script_paths); // Run evaluator in backend const codeTextOnRun = codeText + ''; - fetch('http://localhost:8000/execute', { + fetch(BASE_URL + 'execute', { method: 'POST', headers: {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, body: JSON.stringify({ diff --git a/chain-forge/src/InspectorNode.js b/chain-forge/src/InspectorNode.js index c1be30e..9788d85 100644 --- a/chain-forge/src/InspectorNode.js +++ b/chain-forge/src/InspectorNode.js @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import { Handle } from 'react-flow-renderer'; import useStore from './store'; +import {BASE_URL} from './store'; const bucketResponsesByLLM = (responses) => { let responses_by_llm = {}; @@ -30,7 +31,7 @@ const InspectorNode = ({ data, id }) => { console.log(input_node_ids); // Grab responses associated with those ids: - fetch('http://localhost:8000/grabResponses', { + fetch(BASE_URL + 'grabResponses', { method: 'POST', headers: {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, body: JSON.stringify({ diff --git a/chain-forge/src/PromptNode.js b/chain-forge/src/PromptNode.js index 26b091b..be89611 100644 --- a/chain-forge/src/PromptNode.js +++ b/chain-forge/src/PromptNode.js @@ -8,6 +8,7 @@ import NodeLabel from './NodeLabelComponent' import TemplateHooks from './TemplateHooksComponent' import LLMList from './LLMListComponent' import AlertModal from './AlertModal' +import {BASE_URL} from './store'; // Available LLMs const allLLMs = [ @@ -186,7 +187,7 @@ const PromptNode = ({ data, id }) => { }; // Run all prompt permutations through the LLM to generate + cache responses: - fetch('http://localhost:8000/queryllm', { + fetch(BASE_URL + 'queryllm', { method: 'POST', headers: {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, body: JSON.stringify({ diff --git a/chain-forge/src/ScriptNode.js b/chain-forge/src/ScriptNode.js index 5fd0823..adb662c 100644 --- a/chain-forge/src/ScriptNode.js +++ b/chain-forge/src/ScriptNode.js @@ -58,14 +58,6 @@ const ScriptNode = ({ data, id }) => { setDataPropsForNode(id, new_data); }, [data, id, setDataPropsForNode]); - // Dynamically update the y-position of the template hook s - const ref = useRef(null); - const [hooksY, setHooksY] = useState(120); - useEffect(() => { - const node_height = ref.current.clientHeight; - setHooksY(node_height + 70); - }, [scriptFiles]); - return (
diff --git a/chain-forge/src/VisNode.js b/chain-forge/src/VisNode.js index 4a334a7..615f55f 100644 --- a/chain-forge/src/VisNode.js +++ b/chain-forge/src/VisNode.js @@ -4,7 +4,8 @@ import useStore from './store'; import Plot from 'react-plotly.js'; import { hover } from '@testing-library/user-event/dist/hover'; import { create } from 'zustand'; -import NodeLabel from './NodeLabelComponent' +import NodeLabel from './NodeLabelComponent'; +import {BASE_URL} from './store'; // Helper funcs const truncStr = (s, maxLen) => { @@ -54,7 +55,7 @@ const VisNode = ({ data, id }) => { // Grab the input node ids const input_node_ids = [data.input]; - fetch('http://localhost:8000/grabResponses', { + fetch(BASE_URL + 'grabResponses', { method: 'POST', headers: {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, body: JSON.stringify({ diff --git a/chain-forge/src/store.js b/chain-forge/src/store.js index 0354426..f058c3f 100644 --- a/chain-forge/src/store.js +++ b/chain-forge/src/store.js @@ -33,6 +33,8 @@ const initialEdges = [ { id: 'e1-2', source: initprompt, target: initeval, interactionWidth: 100}, ]; +export const BASE_URL = 'http://localhost:8000/'; + // TypeScript only // type RFState = { // nodes: Node[]; @@ -81,7 +83,7 @@ const useStore = create((set, get) => ({ )(get().nodes) }); }, - getNode: (id) => get().nodes.find(n => n.id == id), + getNode: (id) => get().nodes.find(n => n.id === id), addNode: (newnode) => { set({ nodes: get().nodes.concat(newnode) @@ -122,4 +124,4 @@ const useStore = create((set, get) => ({ }, })); -export default useStore; \ No newline at end of file +export default useStore; diff --git a/python-backend/app.py b/python-backend/app.py index 4070ee5..0ef553a 100644 --- a/python-backend/app.py +++ b/python-backend/app.py @@ -160,8 +160,6 @@ def queryLLM(): """ data = request.get_json() - print('got a request!', data) - # Check that all required info is here: if not set(data.keys()).issuperset({'llm', 'prompt', 'vars', 'id'}): return jsonify({'error': 'POST data is improper format.'}) diff --git a/python-backend/test.html b/python-backend/test.html index b340f9b..110ca67 100644 --- a/python-backend/test.html +++ b/python-backend/test.html @@ -9,7 +9,7 @@