// Example usage with an Express route
app.post("/scoopika", (req, res) => {
	server.handleRequest({
		request: req.body,
		stream: (s) => res.write(s),
		end: () => res.end()
	});
});

Responsible for processing requests sent using the Scoopika client library. You can integrate this method within your API route dedicated to handling Scoopika functionalities. This route can then perform actions like:

  • Running agents and boxes
  • Agents speech
  • Managing history and chat sessions
  • Facilitating real-time streaming between client and server
  • Enabling client-side actions.

Arguments

request
Object
required

The parsed JSON body of the HTTP request sent from the Scoopika client.

stream
function
required

A function used to write data to the HTTP stream in chunks. The implementation of this function will vary depending on your web framework. For example, in Express, this function would be:

(s) => res.write(s)

end
function

In some web frameworks, an additional function might be needed to signal the end of the HTTP stream after processing is complete. This function’s implementation depends on your framework, for example in Express:

() => res.end()

Framework Flexibility

Scoopika aims to support a wide range of web frameworks by allowing you to provide custom stream handling functions. If you encounter any difficulties with this approach, please feel free to contact us for support.

You can find examples of using this with popular web frameworks here.

// Example usage with an Express route
app.post("/scoopika", (req, res) => {
	server.handleRequest({
		request: req.body,
		stream: (s) => res.write(s),
		end: () => res.end()
	});
});