Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(2671): Moved retry logic from infer_type_name to wizard #2672

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 10 additions & 75 deletions src/cli/llm/infer_type_name.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::collections::HashMap;

Check warning on line 1 in src/cli/llm/infer_type_name.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/llm/infer_type_name.rs

use genai::chat::{ChatMessage, ChatRequest, ChatResponse};
use serde::{Deserialize, Serialize};

use super::model::groq;
use super::{Error, Result, Wizard};
use crate::core::config::Config;
Expand Down Expand Up @@ -77,23 +75,21 @@
pub fn new(secret: Option<String>) -> InferTypeName {
Self { secret }
}

pub async fn generate(&mut self, config: &Config) -> Result<HashMap<String, String>> {
let secret = self.secret.as_ref().map(|s| s.to_owned());

let wizard: Wizard<Question, Answer> = Wizard::new(groq::LLAMA38192, secret);

let mut new_name_mappings: HashMap<String, String> = HashMap::new();

// removed root type from types.
let types_to_be_processed = config
.types
.iter()
.filter(|(type_name, _)| !config.is_root_operation_type(type_name))
.collect::<Vec<_>>();

let total = types_to_be_processed.len();
for (i, (type_name, type_)) in types_to_be_processed.into_iter().enumerate() {
// convert type to sdl format.
for (type_name, type_) in types_to_be_processed.into_iter() {
let question = Question {
fields: type_
.fields
Expand All @@ -102,83 +98,22 @@
.collect(),
};

let mut delay = 3;
loop {
let answer = wizard.ask(question.clone()).await;
match answer {
Ok(answer) => {
let name = &answer.suggestions.join(", ");
for name in answer.suggestions {
if config.types.contains_key(&name)
|| new_name_mappings.contains_key(&name)
{
continue;
}
match wizard.ask_with_retry(question).await {
harshtech123 marked this conversation as resolved.
Show resolved Hide resolved
Ok(answer) => {

Check warning on line 102 in src/cli/llm/infer_type_name.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/llm/infer_type_name.rs
for name in answer.suggestions {
if !config.types.contains_key(&name)
&& !new_name_mappings.contains_key(&name) {
new_name_mappings.insert(name, type_name.to_owned());
break;
}
tracing::info!(
"Suggestions for {}: [{}] - {}/{}",
type_name,
name,
i + 1,
total
);

// TODO: case where suggested names are already used, then extend the base
// question with `suggest different names, we have already used following
// names: [names list]`
break;
}
Err(e) => {
// TODO: log errors after certain number of retries.
if let Error::GenAI(_) = e {
// TODO: retry only when it's required.
tracing::warn!(
"Unable to retrieve a name for the type '{}'. Retrying in {}s",
type_name,
delay
);
tokio::time::sleep(tokio::time::Duration::from_secs(delay)).await;
delay *= std::cmp::min(delay * 2, 60);
}
}

Check warning on line 109 in src/cli/llm/infer_type_name.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/llm/infer_type_name.rs
}
Err(e) => {
tracing::error!("Failed to retrieve a name for the type '{}': {:?}", type_name, e);
}
}
}

Ok(new_name_mappings.into_iter().map(|(k, v)| (v, k)).collect())
}
}

#[cfg(test)]
mod test {
use genai::chat::{ChatRequest, ChatResponse, MessageContent};

use super::{Answer, Question};

#[test]
fn test_to_chat_request_conversion() {
let question = Question {
fields: vec![
("id".to_string(), "String".to_string()),
("name".to_string(), "String".to_string()),
("age".to_string(), "Int".to_string()),
],
};
let request: ChatRequest = question.try_into().unwrap();
insta::assert_debug_snapshot!(request);
}

#[test]
fn test_chat_response_parse() {
let resp = ChatResponse {
content: Some(MessageContent::Text(
"{\"suggestions\":[\"Post\",\"Story\",\"Article\",\"Event\",\"Brief\"]}".to_owned(),
)),
..Default::default()
};
let answer = Answer::try_from(resp).unwrap();
insta::assert_debug_snapshot!(answer);
}
}
harshtech123 marked this conversation as resolved.
Show resolved Hide resolved
38 changes: 28 additions & 10 deletions src/cli/llm/wizard.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use derive_setters::Setters;
use tokio_retry::strategy::{ExponentialBackoff, jitter};

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Check Examples

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

failed to resolve: use of undeclared crate or module `tokio_retry`

Check warning on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/llm/wizard.rs

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

failed to resolve: use of undeclared crate or module `tokio_retry`

Check failure on line 1 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

failed to resolve: use of undeclared crate or module `tokio_retry`
use tokio_retry::Retry;

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Check Examples

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

unresolved import `tokio_retry`

Check failure on line 2 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

unresolved import `tokio_retry`
use genai::adapter::AdapterKind;
use genai::chat::{ChatOptions, ChatRequest, ChatResponse};
use genai::Client;

use super::Error;

Check warning on line 6 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/llm/wizard.rs
use super::Result;
use crate::cli::llm::model::Model;
use derive_setters::Setters;

#[derive(Setters, Clone)]
pub struct Wizard<Q, A> {
Expand Down Expand Up @@ -38,15 +40,31 @@
}
}

pub async fn ask(&self, q: Q) -> Result<A>
pub async fn ask_with_retry(&self, q: Q) -> Result<A>
where
Q: TryInto<ChatRequest, Error = super::Error>,
A: TryFrom<ChatResponse, Error = super::Error>,
Q: TryInto<ChatRequest, Error = Error>,
A: TryFrom<ChatResponse, Error = Error>,
{
let response = self
.client
.exec_chat(self.model.as_str(), q.try_into()?, None)
.await?;
A::try_from(response)
let strategy = ExponentialBackoff::from_millis(100).map(jitter).take(5);

let retry_future = Retry::spawn(strategy, || async {
let response = self
.client
.exec_chat(self.model.as_str(), q.clone().try_into()?, None)

Check warning on line 53 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/llm/wizard.rs
.await;

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Check Examples

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

no method named `clone` found for type parameter `Q` in the current scope

Check failure on line 54 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

no method named `clone` found for type parameter `Q` in the current scope

match response {
Ok(res) => {
if res.status_code() == 429 {
Err(Error::GenAI("API rate limit exceeded".into()))

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Check Examples

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

no method named `status_code` found for struct `ChatResponse` in the current scope

Check failure on line 59 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

no method named `status_code` found for struct `ChatResponse` in the current scope
} else {

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Check Examples

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

the trait bound `genai::Error: From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied

Check failure on line 60 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

the trait bound `genai::Error: std::convert::From<&str>` is not satisfied
A::try_from(res).map_err(|e| Error::GenAI(e.to_string()))

Check warning on line 61 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/llm/wizard.rs
}

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Check Examples

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

mismatched types

Check failure on line 62 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

mismatched types
},
Err(e) => Err(Error::GenAI(e.to_string())),
}

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Check Examples

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

mismatched types

Check failure on line 65 in src/cli/llm/wizard.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

mismatched types
});

retry_future.await
}
}
6 changes: 3 additions & 3 deletions tailcall-fixtures/fixtures/configs/yaml-recursive-input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ types:
type: Bar
graphql:
args:
- key: baz
value: '{{.args.baz}}'
- key: baz
value: "{{.args.baz}}"
baseURL: http://localhost
name: bars
Foo:
fields:
name:
type: String
type: String
81 changes: 40 additions & 41 deletions tailcall-wasm/example/browser/index.html
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>hello-wasm example</title>
</head>
<body>
<head>
<meta charset="utf-8" />
<title>hello-wasm example</title>
</head>
<body>
<div id="content">
<!-- Adding input field and button -->
<label for="queryInput"></label><input type="text" id="queryInput" placeholder="Enter your query here" />
<button id="btn">Run Query</button>
<p id="result"></p>
</div>

<div id="content">
<!-- Adding input field and button -->
<label for="queryInput"></label><input type="text" id="queryInput" placeholder="Enter your query here" />
<button id="btn">Run Query</button>
<p id="result"></p>
</div>
<script type="module">
import init, {TailcallBuilder} from "../../browser/pkg/tailcall_wasm.js"
await init()

<script type="module">
import init, { TailcallBuilder } from "../../browser/pkg/tailcall_wasm.js";
await init();
let executor // Making executor accessible

let executor; // Making executor accessible
async function setup() {
try {
const urlParams = new URLSearchParams(window.location.search)
let schemaUrl = urlParams.get("config")

async function setup() {
try {
const urlParams = new URLSearchParams(window.location.search);
let schemaUrl = urlParams.get("config");

let builder = new TailcallBuilder();
builder = await builder.with_config(schemaUrl);
executor = await builder.build();
let btn = document.getElementById("btn");
btn.addEventListener("click", runQuery);
} catch (error) {
alert("error: " + error);
}
}
async function runQuery() {
let query = document.getElementById("queryInput").value;
try {
document.getElementById("result").textContent = await executor.execute(query);
} catch (error) {
console.error("Error executing query: " + error);
document.getElementById("result").textContent = "Error: " + error;
}
}
setup();
</script>
</body>
let builder = new TailcallBuilder()
builder = await builder.with_config(schemaUrl)
executor = await builder.build()
let btn = document.getElementById("btn")
btn.addEventListener("click", runQuery)
} catch (error) {
alert("error: " + error)
}
}
async function runQuery() {
let query = document.getElementById("queryInput").value
try {
document.getElementById("result").textContent = await executor.execute(query)
} catch (error) {
console.error("Error executing query: " + error)
document.getElementById("result").textContent = "Error: " + error
}
}
setup()
</script>
</body>
</html>
Loading