mteb/FreshStackRetrieval huggingface dataset:
I am currently trying my hand at a 3D ARPG in Godot 4.2.1 (and 4.2.2) and have a problem with collision detection. The collision between my projectile (Area3D with CollisionShape3D) collides with an enemy (CharacterBody3D) as expected, but not with instances of StaticBody3D or CSGBox3D.
Setup:

Collision Layer and Mask on Projectile and all Targets set to 1
body entered and area entered signals on the projectile are connected to respective functions in the script projectiles script
Monitoring is enabled

I am wondering if the problem is that the projectile is an Area3D? Or am I missing something obvious?
Thanks in advance.
What i tried:

changing collision layers and masks
changing the speed of the projectile to a stupendously low value
changing the root node of the projectile to a RigidBody3D (resulted in no collision at all, not even with the enemy
I have a main scene and secondary scene. I want to create multiple instances of the secondary scene. The secondary scene will emit a signal with information which is specific to it. The main scene will detect the signal and act on the information.
The main scene is empty. The secondary scene is made of an icon and collision2D to allow detection of mouse clicks:

Secondary.gd:
class_name Secondary extends Area2D
@onready var sprite_2d = $Sprite2D

signal secondary_clicked(value)
var information

func _input(event):
    if event.is_action_pressed("mouse_left_click"):
        secondary_clicked.emit(information)

Main.gd:
class_name Main extends Node2D

# Called when the node enters the scene tree for the first time.
func _ready():
    var secondary_scene = preload("res://Secondary.tscn")
    var secondary_instance = secondary_scene.instantiate()
    add_child(secondary_instance)
    secondary_instance.information = "1st"
    secondary_instance.position = Vector2(510, 320)
    secondary_instance.secondary_clicked.connect(handle_signal)
    
    secondary_instance = secondary_scene.instantiate()
    add_child(secondary_instance)
    secondary_instance.information = "2nd"
    secondary_instance.position = Vector2(710, 320)
    secondary_instance.secondary_clicked.connect(handle_signal) 

func handle_signal(value):
    print("The value from the scene: " + value)

I'm expecting that mouse click will result in "The value from the scene: 1st" or "The value from the scene: 2nd" depending on which instance I clicked.
The actual result is that I get two prints, regardless of which one I clicked. This output was made by a single click:
In the 3d fps tutorial godot documentation, there is a line of code near the bottom that's outdated. I am new to coding with godot, I have a little bit of experience with java script but that's it. The line of code looks like this.
VVV
vel = move_and_slide(vel, Vector3(0, 1, 0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
I know to fix the deg2rad part, it should be deg_to_rad, but once I do that it gives me this error.
Too many arguments for "move_and_slide()" call. Expected at most 0 but received 5.
I don't know what to try because like I said I am new to coding with godot, I understand a little bit of GDScript, but not enough to fix this problem on my own.
It worked once, but in a wrong place. I changed some container size flags, and now it's been 3 hours since all went wrong(
The problem:
I have NinePatchRect (1) inside another NinePatchRect (2) inside GridContainer. I need to pass outer (2) rect's size to the inner (1) one. Both NinePatchRects have textures set at runtime. As I'm working within a container the only way to get starting size would be to set an anchor for (2), otherwise the size would equal to (0, 0). And I can actually see the size.x value change in the editor after assigning the anchors. BUT, once the code is executed, by the time I get to the size.x value, it becomes 0. Even though the texture is placed and shown correctly.
NPR (2) has following size flags:
Horizontal Fill Expand
Vertical Fill
NPR (1) is set to layout_mode POSITION at the position of NPR (2). If I use any anchors, I won't be able to change the size of the rect (which I need to do dynamically).
I actually have a RichTextLabel (of the same size I could use) nearby within the same GridContainer, and I can't get its size value as well, as it turns to (0, 0).
Question:
How do I get the size of GridContainer's child?
Edit:
I did find this post on godot forums which seems to be what I need, but the trick with idle frame doesn't work, as I still get size (0, 0)
I'm currently in the process of making a screen that has ability slots, and it is up to the player to mix and match them and change the order at will. The Drag and Drop functionality worked just fine when it was one-way, but when I tried adding the process of actually swapping the data between the two nodes (should both have any), I keep running into errors.
I have a custom resource called Ability and the slots have a variable called "selected_ability" that takes these and uses it to set the textures and other information.
extends TextureRect
class_name AbilitySlot

@export var selected_ability: Ability

@onready var slot: AbilitySlot = $"."


func _process(_delta):
    if selected_ability:
        slot.texture = selected_ability.icon
    else:
        slot.texture = null
    
func _get_drag_data(_at_position):
    set_drag_preview(get_preview())
    global.origin_slot = self.get_name()
    global.origin_ability = self.selected_ability
    print(global.origin_slot)
    print(global.origin_ability)
    return slot.selected_ability
    
func get_preview():
    var preview_texture = TextureRect.new()
    if selected_ability:
        preview_texture.texture = slot.selected_ability.icon
        preview_texture.expand_mode = 1
        preview_texture.size = Vector2(64,64)
    var preview = Control.new()
    preview.add_child(preview_texture)
 
    return preview
    
func _can_drop_data(_at_position, data):
    global.target_slot = get_name()
    if selected_ability:
        global.target_ability = selected_ability
    else:
        global.target_ability = null
    print(global.target_slot)
    print(global.target_ability)
    return true

func _drop_data(_at_position, data):
    global.origin_slot.selected_ability = global.target_ability         < ERROR
    selected_ability = global.origin_ability


The program crashes at Line 45 (the second from the bottom) with the error "Invalid set index 'selected_ability' (on base: 'StringName') with value of type 'Resource (Ability)'."
If I comment the problematic line out, the program successfully copies the desired contents of the origin slot to the target slot, but the origin slot remains unchanged, so it acts as an infinite duplicate source. I know this because the abilities that slots set up successfully pass onto the next screen, it is only the swap that doesn't work.
What would be the correct way to handle the origin slot if I want to switch data?
Is there a way to use gdscript to obtain the absolute path of "res://" on the current device?
I have encountered some issues that require the use of some code from C #, but the paths "res://" and "users://" cannot be used in C # (non godot API).
I want to know if there is a gdscript method that can obtain the absolute paths of these two paths.
like :
    var dir = DirAccess.open("res://assets/")
    var path = dir.get_current_dir_absolute() # there is no function named that
    print_debug(path) # out put: D://.../assets

or something else.
I tried all the methods of the DirAccess class, but none of them worked.
If someone could tell me how to do this, I would be very grateful!
Firstly, gotta make sure AnimatedSprite2D is the right node to use. I'm making one of those random clicker games where you click a button and get a random chance of getting different items. I need certain items to be rarer than others, and the sprite to show the item you get, but also be able to send info such as that item's rarity, name, etc.
Right now I was thinking of having a bunch of one frame animations on one animated sprite and then using the name of the animation to find the metadata.
If AnimatedSprite2D is the right thing to use, what would the script look like?
I use the following code to display a dragged item preview:
func _get_drag_data(at_position: Vector2) -> Variant:
    var drag_preview := TextureRect.new()
    drag_preview.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
    drag_preview.texture = icon_texture_rect.texture
    drag_preview.custom_minimum_size = Vector2(80, 80)
    drag_preview.modulate = Color(1, 1, 1, 0.75)
    set_drag_preview(drag_preview)
    # return this item slot as the thing to be dragged
    return self

It works, but the dragged rectangle is being dragged by its top-left corner, while I’d like the mouse pointer to drag its middle:

Does anybody please have a suggestion on how to implement this?
I have not found a suitable method in TextureRect and Control docs.
Godot 4.2.2
OS: Mac 14.5 (23F79)
Chip: Apple M2 Pro
I tried to create image dynamically and save it as .jpg image.
func _ready():
    var user_data_dir = OS.get_user_data_dir()
    print("User data directory:", user_data_dir)

    # Create a new image with specified width, height, and format
    var image = Image.new()
    image.create(256, 256, false, Image.FORMAT_RGB8)  # Creating a 256x256 image with RGB format
    
    # Fill the image with black
    image.fill(Color.BLACK)  # Fill the entire image with black color
    
    # Check if the image is empty (filled it with black); i don't think this is necessary but just checking
    var is_empty = true
    for y in range(image.get_height()):
        for x in range(image.get_width()):
            var pixel_color = image.get_pixel(x, y)
            if pixel_color != Color.TRANSPARENT:  # Check against black color with transparent
                is_empty = false
                break
        if not is_empty:
            break

    if is_empty:
        print("The image is empty.")
    else:
        print("The image is not empty.")

    # Save the image as a JPG file
    var file_path_jpg = user_data_dir + "/black_image2.jpg"
    var result_jpg = image.save_jpg(file_path_jpg)

    if result_jpg == OK:
        print("JPG saved successfully at: ", file_path_jpg)
    else:
        print("Failed to save JPG. Error code: ", str(result_jpg))

    # Verify if the file exists
    var jpg_exists = FileAccess.file_exists(file_path_jpg)
    print("JPG exists: ", str(jpg_exists))

Output Log:
User data directory:/Users/xxxx/Library/Application Support/Godot/app_userdata/game
The image is empty.
Failed to save JPG. Error code: 31
JPG exists: true

even thought file created its empty.
I tried to create an RGB8 image, fill it with color, and save it. But for some reason, the saved file is empty. Any idea why this is happening?
Note: I’ve been learning Godot for the past two weeks after switching from Unity, so if this is a newbie question, please bear with me. Thanks!
I also tried to save the png file it didn't even create the png file but i tried with .jpg it created file but with empty data. All the code i have written is in detail section and output log.
I want to create image, write something in image and save that image that's it.
MultiplayerSychronizers keep data updated between players continuously as a game goes on, but is there a way to transfer entire nodes to all the connected clients exactly once? I have a MultiMeshInstance3D that I want to generate once and then never update again, but I don't want to have to individually generate it on each client's computer. Is there a way I can make an override @rpc version of add_child or something?
The MultiMeshInstance3D is a PackedScene, if that's pertinent. I tried adding a MultiplayerSychronizer child that synced the multimesh variable of scene root, but it threw an error from a .cpp file from deep within the base Godot files:

E 0:00:13:0803   get_node: Node not found: "Manager/GameBoard/Map/TileMap/MultiplayerSynchronizer" (relative to "/root").
<C++ Error>    Method/function failed. Returning: nullptr
<C++ Source>   scene/main/node.cpp:1364 @ get_node()
I have a packed scene whose layout is like so:
Control
- Label
- Label
- MenuButton
- RichTextLabel
- SubViewportContainer
- - SubViewport
- - - MeshInstance3D
- - - MeshInstance3D
- - - Camera3D

I instantiate instances of the scene, fill out the necessary details (text for labels, mesh for mesh instances, etc), then add them as children to a VBoxContainer who is the child of a ScrollContainer, but they are only offset by a few pixels, not the 100 pixels the Control node's size.y is set to. I tested it by manually adding instances of the Packed Scene and the same issue occurs. Why is this? How do I fix it?
Need some help.
I have the following json content in a file and would like to use langchain.js and gpt to parse , store and answer question such as
for example:
"find me jobs with 2 year experience" ==> should return a list
"I have knowledge in javascript find me jobs" ==> should return the jobs pbject
I use langchain json loader and I see the file is parse but it say that it find 13 docs . There is only be 3 docs in file . Is the json structure not correct?
Here is snippet of my parse code
const loader = new DirectoryLoader(docPath, {
  ".json": (path) => new JSONLoader(path),
});

const docs = await loader.load();
console.log(docs);
console.log(docs.length);

Here is my input data
[
  {
    "jobid":"job1",
    "title":"software engineer"
    "skills":"java,javascript",
    "description":"this job requires a associate degrees in CS and 2 years experience"
  },
   {
    "jobid":"job2",
    "skills":"math, accounting, spreadsheet",
    "description":"this job requires a degrees in accounting and 2 years experience"
  },
   {
    "jobid":"job3",
    "title":"programmer"
    "skills":"java,javascript,cloud computing",
    "description":"this job requires a ,master degrees in CS and 3 years experience"
  }
  
]

OUTPUT
[
  Document {
    pageContent: 'job1',
    metadata: {
      source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
      line: 1
    }
  },
  Document {
    pageContent: 'software engineer',
    metadata: {
      source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
      line: 2
    }
  },
  Document {
    pageContent: 'java,javascript',
    metadata: {
      source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
      line: 3
    }
  },
  Document {
    pageContent: 'this job requires a associate degrees in CS and 2 years experience',
    metadata: {
      source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
      line: 4
    }
  },
  Document {
    pageContent: 'job2',
    metadata: {
      source: 'langchain-document-loaders-in-node-js/documents/jobs.json',
      line: 5
    }
  },

...
I am playing with langchain/openai/faiss to create chatbot that reads all PDFs, and can answer based on what it learned from them.
What I want to know is there a way to limit answers to knowledge only from documentation, if answer is not in docs bot should respond I do not know or something like that.
Here is the code:
 llm = ChatOpenAI(temperature=0, max_tokens=1000,
                         model_name="gpt-3.5-turbo-16k")
    memory = ConversationBufferMemory(memory_key="chat_history")
    chat = ConversationalRetrievalChain.from_llm(
        llm=llm,retriever=vector_store.as_retriever(),memory=memory)
    
    if "messages" not in st.session_state:
        st.session_state.messages = []

    if not st.session_state.messages:
        welcome_message = {"role": "assistant",
                           "content": "Hello, how can i help?"}
        st.session_state.messages.append(welcome_message)

    for message in st.session_state.messages:
        with st.chat_message(message["role"]):
            st.markdown(message["content"])


    if prompt := st.chat_input("State your question"):
        st.session_state.messages.append({"role": "user", "content": prompt})
        with st.chat_message("user"):
            st.markdown(prompt)
        result = chat({"question": prompt, "chat_history": [
                    (message["role"], message["content"]) for message in st.session_state.messages]})

        with st.chat_message("assistant"):
            full_response = result["answer"]
            st.markdown(full_response)

        st.session_state.messages.append(
            {"role": "assistant", "content": full_response})
I just have a newly created Environment in Anaconda (conda 22.9.0 and Python 3.10.10). Then I proceed to install langchain (pip install langchain if I try conda install langchain it does not work). According to the quickstart guide I have to install one model provider so I install openai (pip install openai).
Then I enter to the python console and try to load a PDF using the class UnstructuredPDFLoader and I get the following error. What the problem could be?
(langchain) C:\Users\user>python
Python 3.10.10 | packaged by Anaconda, Inc. | (main, Mar 21 2023, 18:39:17) [MSC v.1916 64 bit (AMD64)] on win32
>>> from langchain.document_loaders import UnstructuredPDFLoader
>>> loader = UnstructuredPDFLoader("C:\\<path-to-data>\\data\\name-of-file.pdf")
Traceback (most recent call last):
  File "C:\<path-to-anaconda>\envs\langchain\lib\site-packages\langchain\document_loaders\unstructured.py", line 32, in __init__
    import unstructured  # noqa:F401
ModuleNotFoundError: No module named 'unstructured'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\<path-to-anaconda>\envs\langchain\lib\site-packages\langchain\document_loaders\unstructured.py", line 90, in __init__
    super().__init__(mode=mode, **unstructured_kwargs)
  File "C:\<path-to-anaconda>\envs\langchain\lib\site-packages\langchain\document_loaders\unstructured.py", line 34, in __init__
    raise ValueError(
ValueError: unstructured package not found, please install it with `pip install unstructured`
I was following a tutorial on langchain, and after using loader.load() to load a PDF file, it gave me an error and suggested that some dependencies are missing and I should install them using pip install unstructured[local-inference]. So, I did. But it is now installing a whole lot of packages. A whole lot of it includes some packages to do with nvidia-*. Can someone please explain what this command does? It took a good couple of hours for this command to complete.
I am trying to set "gpt-3.5-turbo" model in my OpenAI instance using langchain in node.js, but below way sends my requests defaultly as text-davinci model.
const { OpenAI } = require("langchain/llms");
const { ConversationChain } = require("langchain/chains");
const { BufferMemory } = require("langchain/memory");

const model = new OpenAI({ model:"gpt-3.5-turbo", openAIApiKey: "###", temperature: 0.9 });
const memory = new BufferMemory();

const chain = new ConversationChain({llm:model, memory: memory});

async function x(){
const res = await chain.call({input:"Hello this is xyz!"});
const res2 = await chain.call({input:"Hello what was my name?"});
console.log(res);
console.log(res2);
}

x();

On documentation, i found the way to setting model with python. It sets with model_name attribute on the instance. But this way doesn't work with nodejs. Is there any way to setting custom models with langchain node.js ?
I have a quick question: I'm using the Chroma vector store with LangChain.
And I brought up a simple docsearch with Chroma.from_texts.   I was initially very confused because i thought the similarity_score_with_score would be higher for queries that are close to answers, but it seems from my testing the opposite is true.   Is this becasue it's returning the 'distance' between the two vectors when it searches? I was looking at docs but it only says "List of Documents most similar to the query and score for each" but doesnt explain what 'score' is
Doc reference https://python.langchain.com/en/latest/reference/modules/vectorstores.html?highlight=similarity_search#langchain.vectorstores.Annoy.similarity_search_with_score Can also give more info on the (small to start) dataset im using and queries i tested with.
I am running a langChain process on a node local server.
On my code :
     // Create docs with a loader
const loader = new TextLoader("Documentation/hello.txt");
const docs = await loader.load();

// Create vector store and index the docs
const vectorStore = await Chroma.fromDocuments(docs, new OpenAIEmbeddings(), {
collectionName: "z-test-collection",
});

// Search for the most similar document
const response = await vectorStore.similaritySearch("hello", 1);

console.log(response);

I get the following error message on
const vectorStore = await Chroma.fromDocuments(docs, new OpenAIEmbeddings(), {
collectionName: "z-test-collection",
});:
/home/alexandre/projects/langChain/ProcessGPT/node_modules/chromadb/dist/main/index.js:291
        return response.data;
                        ^
TypeError: Cannot read properties of undefined (reading 'data')
at /home/alexandre/projects/langChain/ProcessGPT/node_modules/chromadb/dist/main/index.js:291:29
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ChromaClient.getOrCreateCollection (/home/alexandre/projects/langChain/ProcessGPT/node_modules/chromadb/dist/main/index.js:286:31)
at async Chroma.ensureCollection (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:60:31)
at async Chroma.addVectors (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:77:28)
at async Chroma.addDocuments (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:52:9)
at async Chroma.fromDocuments (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:121:9)
at async testChroma (/home/alexandre/projects/langChain/ProcessGPT/controllers/backendController.js:31:25)

The same error message appears regardless of the situation in which the method is called.
Are there other requirements appart from the "npm install -S langchain" and "npm install -S chromadb" ?
Thank you in advance
I'm following a tutorial on HuggingFace (let's say this one though getting same result with other Dolly models). I am trying to run predictions with context but receiving empty string as an output. I tried different models and text variations.
Regular question answering works as expected. Only breaks when using questions about the context.
What could be the issue here?
context = """George Washington (February 22, 1732[b] – December 14, 1799) was an American military officer, statesman, and Founding Father who served as the first president of the United States from 1789 to 1797."""
llm_context_chain.predict(instruction="When was George Washington president?", context=context)
Out[5]: ''
PS: I'm using GPU cluster on Azure Databricks if that matters
I'm trying to implement a langchain agent that is able to ask clarifying questions in case some information is missing. Is this at all possible? A simple example would be
Input: "Please give me a recipe for a cake"
Agent: "Certainly. What kind of cake do you have in mind?"
Input: "A chocolate cake"
Agent: "Certainly, here is a recipe for a chocolate cake..."