+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Cargo.lock
.idea/workspace.xml
fluent_cli/.DS_Store
fluent_cli/available_fields_cache.json
fluent_cli/functional_tests/available_fields_cache.json
65 changes: 51 additions & 14 deletions fluent_cli/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"sessionId": "AMBER_FLUENT_SESSION_ID_01",
"bearer_token": "AMBER_REPO_CLOUD_FLUENT_DEMO_KEY",
"overrideConfig": {

"modelName": "gemini-1.5-pro-latest"
},
"tweaks": {

Expand Down Expand Up @@ -172,24 +172,63 @@
"Prompt-sU980": {},
"URL-m0Ust": {
"urls": [
"https://github.com/njfio/fluent_cli"
""
]
},
"ChatOutput-804eN": {
"system_message": "You are a helpful assistant"
},
"OpenAIModel-xHBgn": {
"openai_api_key": "AMBER_FLUENT_OPENAI_API_KEY_01",
"model_name": "gpt-4-turbo-preview"
"model_kwargs": {}
},
"URL-cJhLd": {
"urls": [
"https://www.fluentcli.com"
""
]
},
"TextInput-eohW7": {
"input_value": "Use the references above for style to write a new blog/tutorial about FluentCLI. Suggest non-covered topics."
"record_template": ""
}
},
"timeout_ms": 50000
},
{
"name": "LangFlowChainOfThoughtExample",
"engine": "langflow",
"protocol": "https",
"hostname": "njfio-langflow-preview.hf.space",
"port": 443,
"request_path": "/api/v1/run/",
"chat_id": "2f224ad7-3579-4e4b-8964-18678fd2ee01",
"bearer_token": "AMBER_REPO_CLOUD_FLUENT_DEMO_KEY",
"input_value_key": "input_value",
"input_value": "message",
"sessionId": "",
"output_type": "chat",
"input_type": "chat",
"overrideConfig": {

},
"tweaks": {
"Prompt-DoqBg": {
},
"ChatOutput-g2gga": {},
"OpenAIModel-WvjnV": {
"model_kwargs": {},
"openai_api_key": "AMBER_FLUENT_OPENAI_API_KEY_01"
},
"TextInput-0pH93": {
"input_value": "message"
},
"Prompt-xiPZp": {
},
"OpenAIModel-dCDLX": {
"openai_api_key": "AMBER_FLUENT_OPENAI_API_KEY_01"
},
"ChatOutput-mBx2g": {}
},
"timeout_ms": 50000
},

{
"name": "CohereChainRepoCloud",
Expand Down Expand Up @@ -872,14 +911,12 @@
"sessionId": "",
"bearer_token": "AMBER_MAKE_LEONARDO_IMAGE_POST",
"overrideConfig": {
"modelID": "AMBER_LEONARDO_AI_KINO_XL_MODEL_ID",
"negative_prompt": "words, letters, symbols, hands, deformities, low-quality,",
"alchemy": true,
"photoReal": true,
"photoRealVersion":"v2",
"presetStyle": "",
"makeAuthentication": "AMBER_MAKE_LEONARDO_IMAGE_POST",
"seed": ""
"size": "1024x1792",
"quality":"HD",
"style": "Vivid",
"responseFormat": "url",
"makeAuthentication": "AMBER_MAKE_LEONARDO_IMAGE_POST"

},
"tweaks": {

Expand Down
118 changes: 91 additions & 27 deletions fluent_cli/fluent.ts
Original file line number Diff line number Diff line change
@@ -1,141 +1,205 @@
const completion: Fig.Spec = {
name: "fluent",
description: "Interacts with FlowiseAI, Langflow, and Webhook workflows",
cache: false,
priority: 100000,
parserDirectives: {
optionsMustPrecedeArguments: false,
flagsArePosixNoncompliant: true,
},
args: [
{
name: "flowname",
isCommand:true,
generators: [{
script: ["jq", "-r", ".[].name", "/Users/n/RustroverProjects/fluent_cli/fluent_cli/config.json"],
postProcess: (out: string) => {
return out.split('\n').filter(Boolean).map((name) => {
return { name: name, description: "flow name"}
})
}
}]
name: "flow",
isScript: false,
isOptional: false,
generators: {
script: ["jq", "-r", '.[].name', "/Users/n/RustroverProjects/fluent_cli/fluent_cli/config.json"],
postProcess: (out: string) => {
return out.split('\n').filter(Boolean).map((name) => {
return {
name: name,
description: "Flow name",
icon: "🫠",
};
});
},
},
},
{
name: "request",
optionsCanBreakVariadicArg: true,
description: "Specify the request",
isOptional: false,
isCommand: false,
isOptional: false,
isVariadic: true,
default: "{cursor}",
},
],
options: [
{
name: "-c",
description: "Optional context to include with the request",
isRepeatable: false,
args: {
name: "context",
isOptional: true,
},
},
{
name: ["-i", "--system-prompt-override-inline"],
description: "Overrides the system message with an inline string",
isRepeatable: false,
priority: 99,
args: {
name: "system-prompt-override-inline",
isOptional: true,
description: "Inline system message",
},
},
{
name: ["-f", "--system-prompt-override-file"],
description: "Overrides the system message from a specified file",
isRepeatable: false,
priority: 99,
args: {
name: "system-prompt-override-file",
template: "filepaths",
isVariadic: true,
isVariadic: false,
isOptional: true,
description: "File containing system message",
},
},
{
name: ["-a", "--additional-context-file"],
description: "Specifies a file from which additional request context is loaded",
isRepeatable: false,
priority: 500,
args: {
name: "additional-context-file",
template: "filepaths",
isVariadic: true,
isOptional: true,
description: "File containing additional context",
},
},
{
name: ["-u", "--upload-image-path"],
description: "Sets the input file to use",
priority: 150,
isRepeatable: false,
args: {
name: "upload-image-path",
template: "filepaths",
isVariadic: true,
isOptional: true,
description: "File path for upload",
},
},
{
name: ["-d", "--download-media"],
description: "Downloads all media files listed in the output to a specified directory",
isRepeatable: false,
priority: 500,
args: {
name: "download-media",
template: "folders",
isVariadic: true,
isOptional: true,
description: "Directory to download media files",
},
},
{
name: "--upsert-no-upload",
description: "Sends a JSON payload to the specified endpoint without uploading files",
isRepeatable: false,
priority: 200,
args: {
name: "upsert-no-upload",
isOptional: true,
description: "JSON payload without upload",
},
},
{
name: "--upsert-with-upload",
description: "Uploads a file to the specified endpoint",
isRepeatable: false,
priority: 200,
args: {
name: "upsert-with-upload",
template: "filepaths",
isVariadic: true,
isOptional: true,
description: "File path for upload",
},
},
{
name: ["--generate-autocomplete"],
name: "--generate-autocomplete",
priority: 7,
description: "Generates a bash autocomplete script",

icon: "🔄",
},
{
name: "--generate-fig-autocomplete",
priority: 7,
description: "Generates a fig autocomplete script",
icon: "🔄",
},
{
name: ["-p", "--parse-code-output"],
priority: 400,
description: "Extracts and displays only the code blocks from the response",
exclusiveOn: ["-z", "--full-output", "-m", "--markdown-output"],
icon: "💻",
},
{
name: ["-z", "--full-output"],
priority: 5,
description: "Outputs all response data in JSON format",
exclusiveOn: ["-p", "--parse-code-output", "-m", "--markdown-output"],
icon: "📄",
},
{
name: ["-m", "--markdown-output"],
priority: 400,
description: "Outputs the response to the terminal in stylized markdown. Do not use for pipelines",
},
{
name: "--webhook",
description: "Sends the command payload to the webhook URL specified in config.json",
exclusiveOn: ["-z", "--full-output", "-p", "--parse-code-output"],
icon: "📑",
},
{
name: ["-h", "--help"],
priority: 0,
description: "Print help",
icon: "❓",
},
{
name: ["-V", "--version"],
priority: 0,
description: "Print version",
icon: "ℹ️",
},
{
name: ["-o", "--override"],
description: "Overrides any entry in the config with the specified key-value pair",
isRepeatable: true,
priority: 150,
args: {
name: "override",
description: "KEY=VALUE",
isOptional: false,
generators: {
script: (tokens) => {
const flowName = tokens[1]; // Assuming the flowname is the first argument after the command
if (!flowName) return [];
return [
"jq",
"-r",
`map(select(.name == "${flowName}") | .overrideConfig | paths(scalars) as $p | ($p | map(tostring) | join("."))) | .[]`,
"/Users/n/RustroverProjects/fluent_cli/fluent_cli/config.json"
];
},
postProcess: (out: string) => {
return out.split('\n').filter(Boolean).map((key) => {
return {
name: key,
description: "Config key",
icon: "🔧",
};
});
},
},
},
icon: "🔧",
},
],
};
Expand Down
21 changes: 6 additions & 15 deletions fluent_cli/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ pub async fn upsert_with_json(api_url: &str, flow: &FlowConfig, payload: serde_j
let client = reqwest::Client::new();
debug!("Sending to URL: {}", api_url);
debug!("Payload: {:?}", payload);
eprintln!("Upserting with JSON: {:?}", payload);
eprintln!("Upserting.....");
debug!("Upserting with JSON: {:?}", payload);
let response = client.post(api_url)
.header("Content-Type", "application/json")
.header("Authorization", format!("Bearer {}", bearer_token))
Expand All @@ -416,7 +417,7 @@ pub async fn upsert_with_json(api_url: &str, flow: &FlowConfig, payload: serde_j
if response.status().is_success() {
let response_json: serde_json::Value = response.json().await.map_err(to_serde_json_error)?;
debug!("Success response: {:#?}", response_json);
println!("Success: {:#?}", response_json);
eprintln!("Success: {:#?}", response_json);
} else {
let error_message = format!("Failed to upsert data: Status code: {}", response.status());
return Err(serde_json::Error::custom(error_message));
Expand Down Expand Up @@ -503,8 +504,7 @@ pub async fn prepare_payload(flow: &FlowConfig, question: &str, file_path: Optio
|ctx| format!("\n{}\n{}\n", question, ctx)
);

let full_question_clone = full_question.clone();
let full_question_clone2 = full_question.clone();


debug!("Engine: {}", flow.engine);
let mut body = match flow.engine.as_str() {
Expand Down Expand Up @@ -550,20 +550,11 @@ pub async fn prepare_payload(flow: &FlowConfig, question: &str, file_path: Optio
debug!("Tweaks config before update: {:?}", tweaks_config);
replace_with_env_var(&mut tweaks_config);

let mut flow_clone = flow.clone();

if let Some(obj) = flow_clone.tweaks.as_object_mut() {
if obj.contains_key("user_input") {
obj.insert("user_input".to_string(), serde_json::Value::String(full_question_clone));
}
if obj.contains_key("input_value") {
obj.insert("user_input".to_string(), serde_json::Value::String(full_question_clone2));
}
}

debug!("Tweaks config after update: {:?}", tweaks_config);
serde_json::json!({
"input_value": full_question,
"input_type": flow.input_type,
"output_type:": flow.output_type,
"tweaks": tweaks_config,
})
},
Expand Down
3 changes: 3 additions & 0 deletions fluent_cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct FlowConfig {
pub webhook_url: Option<String>,
pub webhook_headers: Option<Value>,
pub engine: String,
pub input_type: Option<String>,
pub output_type: Option<String>,
pub input_value: Option<String>,
}


Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载