Skip to content

Commit

Permalink
Merge pull request #2 from Bitbaza-Org/node_creation_code
Browse files Browse the repository at this point in the history
added function calling with tabby
  • Loading branch information
VarunJoshi10 authored Apr 7, 2024
2 parents c70be11 + 76eea90 commit 8661aa6
Show file tree
Hide file tree
Showing 10 changed files with 852 additions and 476 deletions.
7 changes: 6 additions & 1 deletion src/api/changeNodePassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export const changeNodePassword = async (params: {
}): Promise<string> => {
try {
const { host, username, currentPassword, newPassword } = params;

console.log(JSON.stringify({
host: host,
username: username,
current_password: currentPassword,
new_password: newPassword
}))
// Make a POST request to change the password
const response = await fetch(`${api_endpoint}/change-password`, {
method: 'POST',
Expand Down
5 changes: 3 additions & 2 deletions src/api/scrapetelegram.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// api.ts
const API_ENDPOINT = "http://43.205.198.30:80/scrape_telegram_member";
const API_ENDPOINT = "https://autosurf.tektorch.info/scrape_telegram_member";

export async function scrapeMembers(apiKey: string, apiHash: string, phoneNumber: string, groupName: string): Promise<void> {
export async function scrapeMembers(apiKey: string, apiHash: string, phoneNumber: string, groupName: string): Promise<string> {
const formData = new FormData();
formData.append('group_name', groupName);
formData.append('api_id', apiKey);
Expand All @@ -27,6 +27,7 @@ export async function scrapeMembers(apiKey: string, apiHash: string, phoneNumber
a.click();
a.remove();
console.log('CSV file downloaded successfully.');
return 'CSV file downloaded successfully.';
} catch (error) {
console.error('Error occurred while fetching data:', error);
throw error; // Propagate the error to the caller
Expand Down
3 changes: 2 additions & 1 deletion src/api/taikoNodeCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export const taikoNodeEnvironmentSetup = async (params: { host: string; username
export const taikoNodeAndDashboardSetup = async (params: { host: string; username: string; password: string; L1_ENDPOINT_HTTP?: string; L1_ENDPOINT_WS?: string; L1_PROPOSER_PRIVATE_KEY?: string; PROPOSE_BLOCK_TX_GAS_LIMIT?: number; BLOCK_PROPOSAL_FEE?: number; }): Promise<string> => {
try {
const { host, username, password, ...otherParams } = params;
const command = `cd taiko_node && ./setup_node.sh ${otherParams.L1_ENDPOINT_HTTP} ${otherParams.L1_ENDPOINT_WS} ${otherParams.L1_PROPOSER_PRIVATE_KEY} ${otherParams.PROPOSE_BLOCK_TX_GAS_LIMIT} ${otherParams.BLOCK_PROPOSAL_FEE} %% ./setup_dashboard`;
const enb="true"
const command = `cd taiko_node && ./setup_node.sh ${otherParams.L1_ENDPOINT_HTTP} ${otherParams.L1_ENDPOINT_WS} ${enb} ${otherParams.L1_PROPOSER_PRIVATE_KEY} ${otherParams.PROPOSE_BLOCK_TX_GAS_LIMIT} ${otherParams.BLOCK_PROPOSAL_FEE} %% ./setup_dashboard`;

const response = await axios.post(`${api_endpoint}/ssh-command`, {
host,
Expand Down
17 changes: 13 additions & 4 deletions src/api/telegram_auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// api.ts
const API_REQ_ENDPOINT = "http://43.205.198.30:80/request_otp";
const API_CODE_ENDPOINT = "http://43.205.198.30:80/authenticate_with_otp";
const API_REQ_ENDPOINT = "https://autosurf.tektorch.info/request_otp";
const API_CODE_ENDPOINT = "https://autosurf.tektorch.info/authenticate_with_otp";

export async function requestCode(api_id: string, api_hash: string, phone: string): Promise<void> {
export async function requestCode(api_id: string, api_hash: string, phone: string): Promise<string> {
const formData = new FormData();
formData.append('api_id', api_id);
formData.append('api_hash', api_hash);
Expand All @@ -19,6 +19,10 @@ export async function requestCode(api_id: string, api_hash: string, phone: strin
const data = await response.json();
console.log(data); // Handle response from FastAPI
console.log("otp sent successfully!"); // Call function to display success message
localStorage.setItem('telegramApiKey', api_id);
localStorage.setItem('telegramApiHash', api_hash);

return "otp sent successfully!"; // Call function to display success message
} else {
throw new Error('Network response was not ok.');
}
Expand All @@ -28,7 +32,7 @@ export async function requestCode(api_id: string, api_hash: string, phone: strin
}
}

export async function authenticateCode(phone: string,code:string): Promise<void> {
export async function authenticateCode(phone: string,code:string): Promise<string> {
const formData = new FormData();
formData.append('phone', phone);
formData.append('code', code);
Expand All @@ -44,6 +48,11 @@ export async function authenticateCode(phone: string,code:string): Promise<void>
const data = await response.json();
console.log(data); // Handle response from FastAPI
console.log("Authenticated successfully!"); // Call function to display success message

localStorage.setItem('telegramPhoneNumber', phone);
localStorage.setItem('telegramlogin', 'true');

return "Authenticated successfully!"; // Call function to display success message
} else {
throw new Error('Network response was not ok.');
}
Expand Down
54 changes: 27 additions & 27 deletions src/common/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const App: React.FC = () => {
useEffect(() => {
// Check local storage to see if the user has already logged in
const isUserLoggedIn = localStorage.getItem('userLoggedIn');
if (isUserLoggedIn==='true') {
if (isUserLoggedIn === 'true') {
console.log(isUserLoggedIn)
setLoggedIn(true);
}else{
} else {
setLoggedIn(false)
}
}, []);

const handleLogout = () => {
localStorage.setItem('userLoggedIn', 'false');
setLoggedIn(false);
Expand All @@ -42,9 +42,9 @@ const App: React.FC = () => {
}

// Call the parent component callback with the selected file and message

};


return (
<ChakraProvider>
Expand All @@ -61,40 +61,40 @@ const App: React.FC = () => {
<Heading as="h1" size="lg" flex={1}>
ZkSurf
</Heading>
{loggedIn ?(
{/* {loggedIn ?(
<Button
onClick={handleLogout}
colorScheme="red"
>
Logout
</Button>):NaN}
</Button>):NaN} */}
<HStack spacing={2}>
<ModelDropdown />
<OptionsDropdown />
</HStack>
</HStack>
</Box>
{loggedIn ? (
<Tabs>
<TabList>
<Tab>Browser Automation</Tab>
<Tab>Chat</Tab>
</TabList>
<TabPanels>
<TabPanel>
<AppUI />
</TabPanel>
<TabPanel>
<ChatUI/>
</TabPanel>
</TabPanels>
</Tabs>

) : (

{/* {loggedIn ? ( */}
<Tabs>
<TabList>
<Tab>Browser Automation</Tab>
<Tab>Chat</Tab>
</TabList>
<TabPanels>
<TabPanel>
<AppUI />
</TabPanel>

<TabPanel>
<ChatUI />
</TabPanel>
</TabPanels>
</Tabs>

{/* ) : (
<LoginComponent />
)}
)} */}

</Box>
</ChakraProvider>
Expand Down
Loading

0 comments on commit 8661aa6

Please sign in to comment.