-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from SkywardAI/new-functions
chat function implemented
- Loading branch information
Showing
8 changed files
with
48 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const VERSION = '0.0.1' | ||
export const VERSION = '0.1.0' | ||
export const LOCAL_API_ADDRESS = 'http://localhost:8000/api' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { LOCAL_API_ADDRESS } from "../settings.js"; | ||
import useSessionId from "../global/useSessionId.js"; | ||
|
||
let session_id = ''; | ||
useSessionId(id=>{session_id = id}); | ||
|
||
export default function request(url, options={}) { | ||
const headers = { | ||
Accept: 'application/json' | ||
} | ||
if(options.method && options.method === 'POST') { | ||
headers['Content-Type'] = 'application/json' | ||
} | ||
if(/^(chat|accounts).*$/.test(url) && session_id) { | ||
headers['Authorization'] = `Bearer ${session_id}` | ||
} | ||
|
||
if(options.body && typeof options.body === 'object') { | ||
options.body = JSON.stringify(options.body) | ||
} | ||
|
||
url = `${LOCAL_API_ADDRESS}/${url}` | ||
return fetch(url, { | ||
headers, | ||
...options | ||
}) | ||
} |