@replicate1 project
Updated 3 days ago
Run AI with an API
@rapilot3302 projects
Updated 3 days ago
@YoungPapi1 project
Updated 3 days ago
@codingpapi1 project
Updated 3 days ago
You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/$%7Bsuccess?q=api&page=2&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=api
Returns an array of strings in format "username" or "username/projectName"
Found 11482 results for "api"(637ms)
19}
2021const { messages, project, branchId, anthropicApiKey, selectedFiles, images } = await c.req.json();
22console.log("Original messages:", JSON.stringify(messages, null, 2));
23console.log("Images received:", JSON.stringify(images, null, 2));
2425// Still allow users to pass their own key, or use ours
26const apiKey = anthropicApiKey || Deno.env.get("ANTHROPIC_API_KEY");
27const anthropic = createAnthropic({
28apiKey,
29});
30
34const TOKEN_KEY = "bearer";
5const ANTHROPIC_KEY = "anthropic_api_key";
67export function useAuth() {
8const [token, setToken, removeToken] = useLocalStorage(TOKEN_KEY, "");
9const [anthropicApiKey, setAnthropicApiKey, removeAnthropicApiKey] = useLocalStorage(ANTHROPIC_KEY, "");
10const [error, setError] = useState(null);
1112const isAuthenticated = !!token;
1314const authenticate = async (valTownAPIKey: string, anthropicKey: string) => {
15// replace all this with oauth when it's ready
16try {
17const res = await fetch("/api/user", {
18headers: {
19"Authorization": "Bearer " + valTownAPIKey,
20},
21});
25setError(data.error);
26removeToken();
27removeAnthropicApiKey();
28return;
29}
30setError(null);
31setToken(valTownAPIKey);
32setAnthropicApiKey(anthropicKey);
33} catch (e) {
34console.error(e);
35setError(e.error);
36removeToken();
37removeAnthropicApiKey();
38}
39};
41const logOut = () => {
42removeToken();
43removeAnthropicApiKey();
44};
4550logOut,
51token,
52anthropicApiKey,
53};
54}