Fixed reset of job desc. to remove agent

Fixed craco for streamingresponse
This commit is contained in:
James Ketr 2025-05-19 17:05:29 -07:00
parent eb9382625a
commit 23a48738a3
7 changed files with 51 additions and 15 deletions

View File

@ -2,18 +2,37 @@ module.exports = {
devServer: { devServer: {
server: { server: {
type: 'https', type: 'https',
// You can also specify custom certificates if needed:
// options: { // options: {
// cert: '/path/to/cert.pem', // cert: '/path/to/cert.pem',
// key: '/path/to/key.pem', // key: '/path/to/key.pem',
// } // }
}, },
proxy: { setupMiddlewares: (middlewares, devServer) => {
'/api': { const { createProxyMiddleware } = require('http-proxy-middleware');
target: 'https://backstory:8911', // Replace with your FastAPI server URL
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}
devServer.app.use('/api', createProxyMiddleware({
target: 'https://backstory:8911',
changeOrigin: true, changeOrigin: true,
secure: false, // Set to true if your FastAPI server uses HTTPS secure: false,
buffer: false,
proxyTimeout: 3600000,
onProxyRes: function(proxyRes, req, res) {
// Remove any header that might cause buffering
proxyRes.headers['transfer-encoding'] = 'chunked';
delete proxyRes.headers['content-length'];
// Set proper streaming headers
proxyRes.headers['cache-control'] = 'no-cache';
proxyRes.headers['content-type'] = 'text/event-stream';
proxyRes.headers['connection'] = 'keep-alive';
}, },
}));
return middlewares;
} }
}, },
webpack: { webpack: {

View File

@ -41,7 +41,7 @@
"web-vitals": "^2.1.4" "web-vitals": "^2.1.4"
}, },
"scripts": { "scripts": {
"start": "HTTPS=true WDS_SOCKET_HOST=backstory-beta.ketrenos.com WDS_SOCKET_PORT=443 craco start", "start": "WDS_SOCKET_HOST=backstory-beta.ketrenos.com WDS_SOCKET_PORT=443 craco start",
"build": "craco build", "build": "craco build",
"test": "craco test" "test": "craco test"
}, },

View File

@ -1,5 +1,7 @@
const getConnectionBase = (loc: any): string => { const getConnectionBase = (loc: any): string => {
if (!loc.host.match(/.*battle-linux.*/)) { if (!loc.host.match(/.*battle-linux.*/)
// && !loc.host.match(/.*backstory-beta.*/)
) {
return loc.protocol + "//" + loc.host; return loc.protocol + "//" + loc.host;
} else { } else {
return loc.protocol + "//battle-linux.ketrenos.com:8912"; return loc.protocol + "//battle-linux.ketrenos.com:8912";

View File

@ -249,7 +249,7 @@ const BackstoryApp = () => {
} }
}; };
fetchSession(); fetchSession();
}, []); }, [cookieSessionId, setSnack, storeInCookie, urlSessionId]);
const copyLink = () => { const copyLink = () => {
const link = `${window.location.origin}${window.location.pathname}?id=${sessionId}`; const link = `${window.location.origin}${window.location.pathname}?id=${sessionId}`;

View File

@ -152,15 +152,21 @@ const ResumeBuilderPage: React.FC<BackstoryPageProps> = (props: BackstoryPagePro
const jobResponse = useCallback(async (message: BackstoryMessage) => { const jobResponse = useCallback(async (message: BackstoryMessage) => {
if (message.actions && message.actions.includes("job_description")) { if (message.actions && message.actions.includes("job_description")) {
if (jobConversationRef.current) {
await jobConversationRef.current.fetchHistory(); await jobConversationRef.current.fetchHistory();
} }
}
if (message.actions && message.actions.includes("resume_generated")) { if (message.actions && message.actions.includes("resume_generated")) {
if (resumeConversationRef.current) {
await resumeConversationRef.current.fetchHistory(); await resumeConversationRef.current.fetchHistory();
}
setHasResume(true); setHasResume(true);
setActiveTab(1); // Switch to Resume tab setActiveTab(1); // Switch to Resume tab
} }
if (message.actions && message.actions.includes("facts_checked")) { if (message.actions && message.actions.includes("facts_checked")) {
if (factsConversationRef.current) {
await factsConversationRef.current.fetchHistory(); await factsConversationRef.current.fetchHistory();
}
setHasFacts(true); setHasFacts(true);
} }
}, [setHasFacts, setHasResume, setActiveTab]); }, [setHasFacts, setHasResume, setActiveTab]);

View File

@ -261,9 +261,11 @@ class WebServer:
) )
if self.ssl_enabled: if self.ssl_enabled:
allow_origins = ["https://battle-linux.ketrenos.com:3000"] allow_origins = ["https://battle-linux.ketrenos.com:3000",
"https://backstory-beta.ketrenos.com"]
else: else:
allow_origins = ["http://battle-linux.ketrenos.com:3000"] allow_origins = ["http://battle-linux.ketrenos.com:3000",
"http://backstory-beta.ketrenos.com"]
logger.info(f"Allowed origins: {allow_origins}") logger.info(f"Allowed origins: {allow_origins}")
@ -470,6 +472,9 @@ class WebServer:
) )
continue continue
logger.info(f"Resetting {reset_operation} for {mode}") logger.info(f"Resetting {reset_operation} for {mode}")
if mode != "chat":
logger.info(f"Removing agent {tmp.agent_type} from {context_id}")
context.remove_agent(tmp)
tmp.conversation.reset() tmp.conversation.reset()
response["history"] = [] response["history"] = []
response["context_used"] = agent.context_tokens response["context_used"] = agent.context_tokens

View File

@ -140,6 +140,10 @@ class Context(BaseModel):
) )
self.agents.append(agent) self.agents.append(agent)
def remove_agent(self, agent: AnyAgent) -> None:
"""Remove an Agent from the context based on its agent_type."""
self.agents = [a for a in self.agents if a.agent_type != agent.agent_type]
def get_agent(self, agent_type: str) -> Agent | None: def get_agent(self, agent_type: str) -> Agent | None:
"""Return the Agent with the given agent_type, or None if not found.""" """Return the Agent with the given agent_type, or None if not found."""
for agent in self.agents: for agent in self.agents: